Add PostgreSQL JDBC database module - #725
Open
dsudomoin wants to merge 2 commits into
Open
Conversation
Dependency Update ReportUpdate level: Found
|
dsudomoin
force-pushed
the
feature/postgres-jdbc-module
branch
from
July 15, 2026 19:15
fddf1bb to
45b5143
Compare
Introduces database-jdbc-postgres with PostgreSQL-specific JDBC mappers, and refactors the monolithic JdbcMapperModule in database-jdbc into focused mapper modules the new module builds upon. database-jdbc (refactor + additions): - Split JdbcMapperModule into PrimitiveJdbcMappersModule, TemporalJdbcMappersModule (incl. Instant) and CollectionJdbcResultSetMappersModule - SQL array infrastructure (ArrayColumnData, Collection<->array mappers) - Enum mapping foundation (EnumColumnData<E,V> supporting name/ordinal/custom value and native type, with value-mapper delegation) database-jdbc-postgres (new): - PostgresJdbcDatabaseModule aggregating the Postgres mappers - PgIntervalJdbcMappersModule: Duration and Period <-> PGInterval - PostgresArrayColumnDataModule: array defaults incl. enum arrays; = ANY(?) support - Native enum via PGobject with correct SQL NULL handling for typed columns - @JSON <-> PGobject(jsonb) bridge (json as compileOnly, opt-in module) - Range types: int4/int8/num/date/ts/tstz with quoted bounds All mappers covered by unit tests and Testcontainers integration round-trips. Claude-Session: https://claude.ai/code/session_019pHSDuY1pScyt8n3ExdVHm
bigDecimalJsonReader now accepts a VALUE_STRING token (e.g. "123.45") in addition to numeric tokens, so a BigDecimal serialized as a JSON string round-trips without losing precision. Claude-Session: https://claude.ai/code/session_019pHSDuY1pScyt8n3ExdVHm
dsudomoin
force-pushed
the
feature/postgres-jdbc-module
branch
from
July 15, 2026 21:51
45b5143 to
ee954c7
Compare
Squiry
requested changes
Jul 20, 2026
| import java.math.BigDecimal; | ||
| import java.nio.charset.StandardCharsets; | ||
|
|
||
| class JsonNumberTests extends Assertions implements JsonModule { |
Contributor
There was a problem hiding this comment.
Зачем?
И сообщи там агенту, что экстендить Assertions - рак.
| @@ -230,8 +230,9 @@ default JsonWriter<BigDecimal> bigDecimalJsonWriter() { | |||
| default JsonReader<BigDecimal> bigDecimalJsonReader() { | |||
| return parser -> switch (parser.currentToken()) { | |||
| case VALUE_NULL -> null; | |||
Contributor
There was a problem hiding this comment.
Таким образом нарушился контракт между reader-writer, так что нет.
| package io.koraframework.database.jdbc; | ||
|
|
||
| @FunctionalInterface | ||
| public interface JdbcEnumValueMappingStrategy { |
Contributor
There was a problem hiding this comment.
Нет, я этот мусор один раз не пропустил и второй раз не пропущу.
| import java.util.Optional; | ||
| import java.util.Set; | ||
|
|
||
| public interface CollectionJdbcResultSetMappersModule { |
Contributor
There was a problem hiding this comment.
Не думаю, что кому-то нужно селектить сеты и коллекции вместо листов.
| import java.time.Duration; | ||
| import java.time.Period; | ||
|
|
||
| public interface PgIntervalJdbcMappersModule { |
Contributor
There was a problem hiding this comment.
Все мапперы в модулях должны поставляться с тегом.
|
|
||
| import java.util.function.Function; | ||
|
|
||
| public record ArrayColumnData<T>(String sqlTypeName, |
Contributor
There was a problem hiding this comment.
Давайте не хранить какую-то мутную метадату, а просто если очень уж хочется сделать маппер в обе стороны и класть в контейнер его, а не врапперы мапперов.
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.
Summary
New
database-jdbc-postgresmodule with PostgreSQL-specific JDBC mappers, plus arefactor of
database-jdbcthat splits the monolithicJdbcMapperModuleintofocused mapper modules the new module builds on.
database-jdbc (refactor + additions)
PrimitiveJdbcMappersModule,TemporalJdbcMappersModule(incl.Instant),CollectionJdbcResultSetMappersModuleArrayColumnData,Collection↔array mappers)EnumColumnData<E,V>— name / ordinal / custom value / native type,with value-mapper delegation
database-jdbc-postgres (new)
PostgresJdbcDatabaseModuleaggregatorPgIntervalJdbcMappersModule:DurationandPeriod↔PGIntervalPostgresArrayColumnDataModule: array defaults incl. enum arrays;= ANY(?)for IN-listsPGobjectwith correct SQLNULLhandling for typed columns@Json↔PGobject(jsonb)bridge (json ascompileOnly, opt-in module)int4/int8/num/date/ts/tstzwith quoted boundsjson-common
bigDecimalJsonReadernow also readsBigDecimalfrom a JSON string (VALUE_STRING),not just numeric tokens
Testing
./gradlew :database:database-jdbc:test :database:database-jdbc-postgres:test :json:json-common:test— greenPostgreSQL: arrays,
= ANY(?), ranges (incl. ts/tstz), native enum (incl. NULL), jsonb,Duration/Period intervals