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

Update existing JSONB queries to use whereJsonPath #332

Merged
merged 2 commits into from
Aug 3, 2023

Conversation

Cruikshanks
Copy link
Member

When working on Fix 2PT query we needed to update a where clause in an Objection query to use a JSONB field.

We'd done this a number of times in our tear-down service and thought we had to use Knex's raw(). But we happened to see there was also a whereRaw() method and whilst on the page whereJsonPath().

This avoids us having to drop down to raw() and is much more in keeping with our preference; first try Objection, then Knex, and only raw() if you really have to.

To keep things consistent, this updates our existing uses to use whereJsonPath().

When working on [Fix 2PT query](#331) we needed to update a where clause in an Objection query to use a JSONB field.

We'd done this a number of times in our tear down service and thought we had to use [Knex's raw()](https://knexjs.org/guide/raw.html). But we happened to see there was also a [whereRaw()](https://knexjs.org/guide/query-builder.html#whereraw) method and whilst on the page [whereJsonPath()](https://knexjs.org/guide/query-builder.html#wherejsonpath).

This avoids us having to drop down to `raw()` and is much more in keeping with our preference; first try Objection, then Knex, and only `raw()` if you really have to.

To keep things consistent, this updates our existing uses to use `whereJsonPath()`.
@Cruikshanks Cruikshanks added the housekeeping Refactoring, tidying up or other work which supports the project label Aug 3, 2023
@Cruikshanks Cruikshanks self-assigned this Aug 3, 2023
@Cruikshanks Cruikshanks marked this pull request as ready for review August 3, 2023 08:51
@Cruikshanks Cruikshanks merged commit 3a33a2e into main Aug 3, 2023
@Cruikshanks Cruikshanks deleted the use-where-json-path-instead-of-raw branch August 3, 2023 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
housekeeping Refactoring, tidying up or other work which supports the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants