Repository navigation
feat: map JSON and JSONB columns to String - #51
Merged
Merged
Conversation
Generated code passes JSON and JSONB arguments as UntypedText so PostgreSQL types the text from its context, and reads those columns with getString. The text is never parsed or normalized.
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
PostgreSQL
JSONandJSONBcolumns now map toStringholding the JSON text, for both query parameters and result components. PostgreSQL rejects text bound asvarcharfor these types, and the driver does not support reading them throughgetObject(position, String.class). So generated code passes JSON arguments through a new runtime value that is bound without a declared SQL type, and reads JSON columns withgetString.Changes
JSONandJSONB, in any case, inCREATE TABLE,ALTER TABLE ... ADD COLUMN, andALTER COLUMN ... TYPE. Both resolve toString, and nullability is parsed as for any other column.dev.sqlcj.runtime.UntypedText, a record carrying any text.JdbcQueryExecutorbinds it withsetObject(position, value, Types.OTHER), so PostgreSQL types the text, or a null, from the context of its placeholder. Every other argument is bound exactly as before.JSONorJSONBargument asnew dev.sqlcj.runtime.UntypedText(value)at every binding position of its placeholder, and readJSONandJSONBcolumns withresultSet.getString(position). Generated imports are unchanged, and output for all other types is byte-for-byte the same.JSONreads back exactly as written.JSONBreads back as PostgreSQL renders it, and=on aJSONBcolumn matches by value.JSONBequality lookup.Scope and non-goals
json[]andjsonb[]columns stay recorded as unsupported types.