feat: type-safe JSON insertions/updates, eb.jval & sql.jval.#1130
Open
igalklebanov wants to merge 7 commits into
Open
feat: type-safe JSON insertions/updates, eb.jval & sql.jval.#1130igalklebanov wants to merge 7 commits into
eb.jval & sql.jval.#1130igalklebanov wants to merge 7 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Serialized<O>, stricter JSONColumnType<O>, eb.valSerialized & sql.valSerialized.Serialized<O>, stricter JSONColumnType<O> insertions/updates, eb.valSerialized & sql.valSerialized.
Serialized<O>, stricter JSONColumnType<O> insertions/updates, eb.valSerialized & sql.valSerialized.JSONColumnType<O> insertions/updates, eb.valSerialized & sql.valSerialized.
JSONColumnType<O> insertions/updates, eb.valSerialized & sql.valSerialized.JSONColumnType<O> insertions/updates, eb.valSerialized & sql.valSerialized.
JSONColumnType<O> insertions/updates, eb.valSerialized & sql.valSerialized.JSONColumnType<O> insertions/updates, eb.valJson & sql.valJson.
JSONColumnType<O> insertions/updates, eb.valJson & sql.valJson.eb.valJson & sql.valJson.
igalklebanov
force-pushed
the
v0.28
branch
2 times, most recently
from
October 3, 2024 22:55
a84367a to
124c0dc
Compare
igalklebanov
force-pushed
the
stricter-json
branch
from
October 3, 2024 23:27
8e3dbf7 to
a7abe0f
Compare
igalklebanov
force-pushed
the
v0.28
branch
3 times, most recently
from
October 24, 2024 12:39
b2b78db to
ae5cb1e
Compare
igalklebanov
force-pushed
the
stricter-json
branch
from
October 27, 2024 22:22
a7abe0f to
5262c17
Compare
igalklebanov
force-pushed
the
stricter-json
branch
from
November 3, 2024 18:15
5262c17 to
1cda284
Compare
igalklebanov
force-pushed
the
stricter-json
branch
from
November 4, 2024 23:03
1cda284 to
8372531
Compare
igalklebanov
force-pushed
the
stricter-json
branch
from
July 17, 2025 17:02
fff673a to
0044280
Compare
igalklebanov
force-pushed
the
next
branch
2 times, most recently
from
July 25, 2025 22:35
91b22dc to
dc89b9e
Compare
igalklebanov
force-pushed
the
stricter-json
branch
from
July 25, 2025 22:39
0044280 to
009f9f5
Compare
igalklebanov
force-pushed
the
stricter-json
branch
from
July 26, 2025 00:19
009f9f5 to
16cd689
Compare
eb.valJson & sql.valJson.eb.jval & sql.jval.
igalklebanov
marked this pull request as ready for review
July 26, 2025 01:52
igalklebanov
force-pushed
the
stricter-json
branch
from
July 26, 2025 22:57
fc3c620 to
5ce2df7
Compare
Co-authored-by: Eric So <56284867+ericsodev@users.noreply.github.com> Co-authored-by: Igal Klebanov <igalklebanov@gmail.com>
introduce ValueNode.serialized. introduce eb.valSerialized. introduce sql.valSerialized. fix json-traversal test suite. fix null handling @ compiler. rename to `valJson`. add instructions in errors. typings test inserts. call the new type `Json` instead, to not introduce a breaking change. add missing json column @ Getting Started. add `appendSerializedValue`. Renames `valJson` to `jval` for JSON value wrapping Renames the `valJson` method to `jval` for wrapping JSON values when inserting or updating columns. This change promotes brevity and consistency throughout the codebase. The name change affects the expression builder, SQL raw builder, and documentation. fix jsdocs check. ValueNode.createSerialized.
Contributor
|
Love this conceptually, but really think the function name should be more explicit (e.g., |
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.
Hey 👋
JSONColumnTypedemands manual serialization before passing values in insertions/updates. Once you do that, it is not that type-safe - you can pass any string value really.This PR deprecates
JSONColumnType, and introduces the stricterJsontype that enforces type-safe insertions/updates.Using a branded type as the
InsertTypeandUpdateTypeAND as the return value of new serialization helpers inExpressionBuilderandsqltemplate tag, users can now insert/update and serialize their JSON objects/arrays safely into JSON columns.Compilers/plugins can serialize the objects/arrays differently, as the value is passed around in a
ValueNodewith aserializedflag. The default serialization method is, well,JSON.stringify.If you want the non-type-safe old
JSONColumnType.. we don't encourage it, but you can continue usingJSONColumnType(until we decide to remove it) or just use:For a readonly
Json, use: