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

fix(inserts): resolve issues with undefined values #1311

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

naorpeled
Copy link
Contributor

closes #1310

Copy link

vercel bot commented Jan 5, 2025

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 Jan 5, 2025 9:05pm

Copy link

pkg-pr-new bot commented Jan 5, 2025

Open in Stackblitzkysely_koa_example

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

commit: 15bcf77

@koskimas
Copy link
Member

koskimas commented Jan 6, 2025

Looking good otheriwse but: when inserting a single row, the value should actually be missing and not DEFAULT. The change now caused DEFAULT being used even when you insert a single row with an undefined value (see all the failing tests).

Most databases support DEFAULT but not all. For example on sqlite we need to use null instead. Mapping undefined to null is not a good idea when it can be avoided.

@naorpeled
Copy link
Contributor Author

Looking good otheriwse but: when inserting a single row, the value should actually be missing and not DEFAULT. The change now caused DEFAULT being used even when you insert a single row with an undefined value (see all the failing tests).

Most databases support DEFAULT but not all. For example on sqlite we need to use null instead. Mapping undefined to null is not a good idea when it can be avoided.

Makes sense,
how would you separate those two cases in the cleanest way?

@koskimas
Copy link
Member

koskimas commented Jan 7, 2025

how would you separate those two cases in the cleanest way?

Don't know. Maybe just a special case when rows.length === 1? Add a comment why the special case is there in case you end up with this solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Batch inserts use "undefined" instead of falling back on default value
2 participants