Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add eb.jsonPath<$>. #791

Merged
merged 7 commits into from
Dec 29, 2023
Merged

add eb.jsonPath<$>. #791

merged 7 commits into from
Dec 29, 2023

Conversation

igalklebanov
Copy link
Member

@igalklebanov igalklebanov commented Dec 2, 2023

closes #790.

This PR exposes the JSONPathBuilder from #440, for type-safe building of standalone JSON paths (just the $.key[at] strings). These are required in some JSON functions, e.g. json_set (MySQL/SQLite).

(eb) => eb.jsonPath<'column'>().key('key').at(0)

The generic dictates the $ root document type - not providing it returns a KyselyTypeError. This aligns with WYSIWYG since it is not part of the generated SQL. The alternative was requesting a runtime argument - it just felt awkward.

The generated SQL:

'$.key[0]'

Copy link

vercel bot commented Dec 2, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
kysely ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 29, 2023 4:14pm

@igalklebanov igalklebanov added enhancement New feature or request api Related to library's API labels Dec 2, 2023
@igalklebanov igalklebanov marked this pull request as ready for review December 2, 2023 20:32
@igalklebanov igalklebanov changed the title add eb.jsonPath. add eb.jsonPath<$>. Dec 2, 2023
@koskimas koskimas merged commit b39a6bd into kysely-org:master Dec 29, 2023
5 checks passed
@igalklebanov igalklebanov deleted the json-path branch December 29, 2023 16:55
thecodrr pushed a commit to thecodrr/kysely that referenced this pull request Sep 3, 2024
* extend json path builder to hold a JSONPathNode.

* add eb.jsonPath.

* eb.jsonPath tests.

* no runtime arg. this is just type-level arg.

* brand the generic as `$`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Related to library's API enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose standalone JSON path builder @ ExpressionBuilder.
2 participants