feat: add PostgreSQL dialect support#23
Open
hmdnnrmn wants to merge 6 commits into
Open
Conversation
- add SqlDialect abstraction and database-specific implementations for MySQL, MariaDB, SQLite, and PostgreSQL - add PostgreSQL connection/configuration support and JDBC dependency wiring - route SQL rendering through dialects for identifiers, DDL, joins, where clauses, upserts, and migration metadata checks - fix PostgreSQL-specific regressions (where-clause quoting, batch request quoting, case-preserving migration column detection) - add foreign key/order-by value objects and dialect-aware schema rendering - add PostgreSQL-focused regression and behavior tests across dialect, connection, conditions, create, upsert, migration, and request SQL generation - document PostgreSQL usage in README and bump library version to 1.24
- Override columnType() in PostgreSqlDialect to remap LONGTEXT, MEDIUMTEXT, TINYTEXT -> TEXT and BLOB, LONGBLOB, MEDIUMBLOB, TINYBLOB -> BYTEA for PostgreSQL compatibility - Gate MySQL/MariaDB-specific HikariCP data source properties (useSSL, useUnicode, characterEncoding) to MySQL/MariaDB only - Add PostgreSQL-specific socketTimeout (in seconds, not ms) - Add PostgreSqlTypeMappingTest with 9 test cases
Comment on lines
505
to
+508
| public long executeSelectCount(DatabaseConnection databaseConnection, Logger logger) throws SQLException { | ||
| SqlDialect dialect = SqlDialects.from(databaseConnection.getDatabaseConfiguration().getDatabaseType()); | ||
| StringBuilder selectQuery = new StringBuilder("SELECT COUNT(*) FROM " + tableName); | ||
| this.whereConditions(selectQuery); | ||
| this.whereConditions(selectQuery, dialect); |
Comment on lines
550
to
554
|
|
||
| if (!this.joinConditions.isEmpty()) { | ||
| for (JoinCondition join : this.joinConditions) { | ||
| selectQuery.append(" ").append(join.getJoinClause()); | ||
| selectQuery.append(" ").append(join.getJoinClause(dialect)); | ||
| } |
Comment on lines
46
to
48
| @@ -39,9 +47,18 @@ public String getCondition() { | |||
| if (this.whereAction == WhereAction.IS_NOT_NULL) return this.column + " IS NOT NULL"; | |||
| if (this.whereAction == WhereAction.IS_NULL) return this.column + " IS NULL"; | |||
Comment on lines
42
to
+47
| DatabaseType databaseType = databaseConfiguration.getDatabaseType(); | ||
| SqlDialect dialect = SqlDialects.from(databaseType); | ||
|
|
||
| // URL + Driver | ||
| final String jdbcUrl; | ||
| if (databaseType == DatabaseType.MARIADB) { | ||
| jdbcUrl = "jdbc:mariadb://" + databaseConfiguration.getHost() + ":" + databaseConfiguration.getPort() + "/" + databaseConfiguration.getDatabase() + "?allowMultiQueries=true"; | ||
| config.setDriverClassName("org.mariadb.jdbc.Driver"); | ||
| } else { | ||
| jdbcUrl = "jdbc:mysql://" + databaseConfiguration.getHost() + ":" + databaseConfiguration.getPort() + "/" + databaseConfiguration.getDatabase() + "?allowMultiQueries=true"; | ||
| config.setDriverClassName("com.mysql.cj.jdbc.Driver"); | ||
| } | ||
| config.setJdbcUrl(jdbcUrl); | ||
| config.setJdbcUrl(dialect.jdbcUrl(databaseConfiguration)); | ||
| config.setDriverClassName(dialect.driverClassName()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
add SqlDialect abstraction and database-specific implementations for MySQL, MariaDB, SQLite, and PostgreSQL
add PostgreSQL connection/configuration support and JDBC dependency wiring
route SQL rendering through dialects for identifiers, DDL, joins, where clauses, upserts, and migration metadata checks
fix PostgreSQL-specific regressions (where-clause quoting, batch request quoting, case-preserving migration column detection)
add foreign key/order-by value objects and dialect-aware schema rendering
add PostgreSQL-focused regression and behavior tests across dialect, connection, conditions, create, upsert, migration, and request SQL generation
document PostgreSQL usage in README and bump library version to 1.24