PostgreSqlType - Change "PGInterval" to "String #5403
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.
PostgreSqlType
INTERVAL
was initially mapped asPgInterval
https://github.com/cashapp/sqldelight/blob/431caee2a99885719b1a43db2e08ef16a3b64af8/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/PostgreSqlType.kt#L21
This 🥨 changes the mapping to
String
asorg.postgresql.util.PgInterval
is a JDBC type and would be consistent with JSON, TSVECTOR, XML type mapping. The client can use a type adapter for the string value to a desired platform type - Duration, Period ... etc. Docs page updated with type mappingRequirement -
Write to an
Interval
column usingsetObject Other
, as this is required for it to interpret as an interval typeRead from an
Interval
column usinggetString
, this is formatted using theintervalstyle
* PG client optionkotlin.time.Duration
column adapter as intended by SqlDelight to encode/decode iso interval valuesNote:
Future Developments
PostgreSqlType
dialect type should not reference JDBC (java.sql) types as not all drivers are JDBCPGobject
types for JSON, Interval that setObject can use