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

feat: add HandleEmtpyInListsPlugin. #925

Merged

Conversation

austinwoon
Copy link

@austinwoon austinwoon commented Mar 29, 2024

Hey 👋

closes #709.

This PR was created initially by @austinwoon, and revisited/expanded by @igalklebanov.

It adds HandleEmptyInListsPlugin to allow you to handle in () and not in () with a chosen strategy.

It ships with 2 strategies out-the-box:

  • replaceWithNoncontingentExpression - Replaces in () with 1 = 0 and not in () with 1 = 1 - the strategy used by Knex.js, PrismaORM, Laravel and SQLAlchemy.
  • pushValueIntoList(uniqueValue: string) - Replaces in () with in (null) - the strategy used by TypeORM and Sequelize, and not in () with cast({{leftOperand}} as char) in ('{{uniqueValue}}').

It also supports custom strategies, e.g.:

  • throw an error so a request is not sent to the database.
  • print a warning and apply one of the built-in strategies.
  • mix the built-in strategies, e.g. in (null) and 1 = 1.

Copy link

vercel bot commented Mar 29, 2024

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 15, 2024 5:42pm

@igalklebanov igalklebanov changed the base branch from master to v0.28 December 8, 2024 17:31
Co-authored-by: Austin Woon Quan <43132101+austinwoon@users.noreply.github.com>
Copy link

pkg-pr-new bot commented Dec 15, 2024

Open in Stackblitzkysely_koa_example

npm i https://pkg.pr.new/kysely-org/kysely@925

commit: 30d5a6a

@igalklebanov igalklebanov changed the title feat: add safe empty where in plugin feat: add HandleEmtpyInListsPlugin. Dec 15, 2024
@igalklebanov igalklebanov merged commit 6be09d8 into kysely-org:v0.28 Dec 15, 2024
24 checks passed
@igalklebanov
Copy link
Member

igalklebanov commented Dec 15, 2024

Went over it and expanded the use case. You can choose which strategy to apply and there are 2 built-in strategies to choose from and support for custom ones.

This'll probably land in v0.28! 🥳

igalklebanov added a commit that referenced this pull request Jan 5, 2025
* feat: empty where in plugin

* test: add new tests

* chore: remove unneccesary typeguards

* fix: change to binary operator node

* test: update tests to do both in and not in

* test: for having

* chore: rm test

* test: nullable tests

* chore: nit

* chore: condense suite

* chore: db config override

* chore: extra console log

* chore: empty arr plugin docs

* HandleEmptyInListsPlugin initial commit.

Co-authored-by: Austin Woon Quan <43132101+austinwoon@users.noreply.github.com>

---------

Co-authored-by: Austin Woon <austin@open.gov.sg>
Co-authored-by: igalklebanov <igalklebanov@gmail.com>
remove only.
@igalklebanov igalklebanov self-assigned this Jan 5, 2025
igalklebanov added a commit that referenced this pull request Jan 9, 2025
* feat: empty where in plugin

* test: add new tests

* chore: remove unneccesary typeguards

* fix: change to binary operator node

* test: update tests to do both in and not in

* test: for having

* chore: rm test

* test: nullable tests

* chore: nit

* chore: condense suite

* chore: db config override

* chore: extra console log

* chore: empty arr plugin docs

* HandleEmptyInListsPlugin initial commit.

Co-authored-by: Austin Woon Quan <43132101+austinwoon@users.noreply.github.com>

---------

Co-authored-by: Austin Woon <austin@open.gov.sg>
Co-authored-by: igalklebanov <igalklebanov@gmail.com>
remove only.
igalklebanov added a commit that referenced this pull request Jan 11, 2025
* feat: empty where in plugin

* test: add new tests

* chore: remove unneccesary typeguards

* fix: change to binary operator node

* test: update tests to do both in and not in

* test: for having

* chore: rm test

* test: nullable tests

* chore: nit

* chore: condense suite

* chore: db config override

* chore: extra console log

* chore: empty arr plugin docs

* HandleEmptyInListsPlugin initial commit.

Co-authored-by: Austin Woon Quan <43132101+austinwoon@users.noreply.github.com>

---------

Co-authored-by: Austin Woon <austin@open.gov.sg>
Co-authored-by: igalklebanov <igalklebanov@gmail.com>
remove only.
igalklebanov added a commit that referenced this pull request Jan 12, 2025
* feat: empty where in plugin

* test: add new tests

* chore: remove unneccesary typeguards

* fix: change to binary operator node

* test: update tests to do both in and not in

* test: for having

* chore: rm test

* test: nullable tests

* chore: nit

* chore: condense suite

* chore: db config override

* chore: extra console log

* chore: empty arr plugin docs

* HandleEmptyInListsPlugin initial commit.

Co-authored-by: Austin Woon Quan <43132101+austinwoon@users.noreply.github.com>

---------

Co-authored-by: Austin Woon <austin@open.gov.sg>
Co-authored-by: igalklebanov <igalklebanov@gmail.com>
remove only.
igalklebanov added a commit that referenced this pull request Jan 17, 2025
* feat: empty where in plugin

* test: add new tests

* chore: remove unneccesary typeguards

* fix: change to binary operator node

* test: update tests to do both in and not in

* test: for having

* chore: rm test

* test: nullable tests

* chore: nit

* chore: condense suite

* chore: db config override

* chore: extra console log

* chore: empty arr plugin docs

* HandleEmptyInListsPlugin initial commit.

Co-authored-by: Austin Woon Quan <43132101+austinwoon@users.noreply.github.com>

---------

Co-authored-by: Austin Woon <austin@open.gov.sg>
Co-authored-by: igalklebanov <igalklebanov@gmail.com>
remove only.
igalklebanov added a commit that referenced this pull request Jan 19, 2025
* feat: empty where in plugin

* test: add new tests

* chore: remove unneccesary typeguards

* fix: change to binary operator node

* test: update tests to do both in and not in

* test: for having

* chore: rm test

* test: nullable tests

* chore: nit

* chore: condense suite

* chore: db config override

* chore: extra console log

* chore: empty arr plugin docs

* HandleEmptyInListsPlugin initial commit.

Co-authored-by: Austin Woon Quan <43132101+austinwoon@users.noreply.github.com>

---------

Co-authored-by: Austin Woon <austin@open.gov.sg>
Co-authored-by: igalklebanov <igalklebanov@gmail.com>
remove only.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
built-in plugin Related to a built-in plugin enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants