Interface JdbcDialect
- All Known Implementing Classes:
H2Dialect, MySqlDialect, PostgresDialect
Vendor abstraction over the small set of column-type / SQL fragments that
differ between MySQL, PostgreSQL and H2. The flow engine itself uses
vendor-neutral parameterised SQL throughout (see
SqlBuilder);
dialects only contribute schema-DDL fragments.
数据库方言抽象:仅在 schema DDL 层面区分 MySQL / PostgreSQL / H2 列类型差异。
流程引擎运行时 SQL 由 SqlBuilder 产出,统一参数化,与方言无关。
The sealed hierarchy enumerates the three officially supported vendors.
detect(String) inspects a JDBC URL prefix to pick the right impl;
any other URL throws IllegalArgumentException.
密封继承层级穷尽三种官方支持的数据库。detect(String) 根据
JDBC URL 前缀挑选实现;不识别的 URL 直接抛 IllegalArgumentException。
- Since:
- JDK 25, opencode-base-flow V1.0.5
- Author:
- Leon Soo
-
Method Summary
Modifier and TypeMethodDescriptionColumn type for boolean columns (e.g.static JdbcDialectDetects the appropriate dialect from a JDBC URL.jsonType()Column type forvariables_json/dsl_json/extra_json.static StringmaskJdbcUrl(String jdbcUrl) Masks a JDBC URL so it can be safely embedded in exception messages or logs.Short identifier used to pick the matchingV1__init_*.sqlscript (one of"mysql"/"postgres"/"h2").Column type forTIMESTAMPcolumns (with microsecond precision, including time-zone where the dialect supports it).
-
Method Details
-
jsonType
String jsonType()Column type forvariables_json/dsl_json/extra_json.variables_json/dsl_json/extra_json列类型。- Returns:
- vendor-specific JSON column type — 方言相关 JSON 类型
- Since:
- JDK 25, opencode-base-flow V1.0.5
-
timestampType
String timestampType()Column type forTIMESTAMPcolumns (with microsecond precision, including time-zone where the dialect supports it).TIMESTAMP列类型(微秒精度,方言支持时含时区)。- Returns:
- vendor-specific timestamp column type — 方言相关 TIMESTAMP 类型
- Since:
- JDK 25, opencode-base-flow V1.0.5
-
booleanType
String booleanType()Column type for boolean columns (e.g.flow_comment_template.enabled). boolean 列类型(如flow_comment_template.enabled)。- Returns:
- vendor-specific boolean column type — 方言相关 boolean 类型
- Since:
- JDK 25, opencode-base-flow V1.0.5
-
shortName
String shortName()Short identifier used to pick the matchingV1__init_*.sqlscript (one of"mysql"/"postgres"/"h2"). 用于挑选V1__init_*.sql脚本的短标识("mysql"/"postgres"/"h2")。- Returns:
- short identifier — 短标识
- Since:
- JDK 25, opencode-base-flow V1.0.5
-
detect
Detects the appropriate dialect from a JDBC URL. 根据 JDBC URL 推断对应方言。Recognised prefixes:
jdbc:mysql:,jdbc:mariadb:,jdbc:postgresql:,jdbc:h2:. Anything else triggersIllegalArgumentException.识别前缀:
jdbc:mysql:、jdbc:mariadb:、jdbc:postgresql:、jdbc:h2:。其它前缀抛IllegalArgumentException。- Parameters:
jdbcUrl- JDBC connection URL — JDBC 连接串- Returns:
- the matching dialect — 对应方言
- Throws:
IllegalArgumentException- when the URL prefix is not recognised — URL 前缀不识别- Since:
- JDK 25, opencode-base-flow V1.0.5
-
maskJdbcUrl
Masks a JDBC URL so it can be safely embedded in exception messages or logs. Returns only thejdbc:<scheme>:prefix; everything after the second colon (host, port, database, query string, and any embeddeduser:password@credentials) is replaced with***. 脱敏 JDBC URL,仅保留jdbc:<scheme>:前缀;host/port/database/ 查询串以及形如user:password@的嵌入凭证统一替换为***。- Parameters:
jdbcUrl- raw JDBC URL (must not benull) — 原始 JDBC URL- Returns:
- masked URL safe for logging — 适合写日志的脱敏 URL
- Since:
- JDK 25, opencode-base-flow V1.0.5
-