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

Evaluated multi insert default for undefined already in query compiler #1396

Merged
merged 3 commits into from May 13, 2016

Conversation

Projects
None yet
3 participants
@elhigu
Copy link
Collaborator

elhigu commented May 10, 2016

Drivers cannot take knex.raw replacement values as positional replacement values, so they must be evaluated already in query compile time to sql string which is passed to driver.

@elhigu

This comment has been minimized.

Copy link
Collaborator Author

elhigu commented May 11, 2016

Added implementation to work with same principle with every dialect. Now knex.raw('DEFAULT') is not passed until driver, but is already lowered accordingly by query compiler. After this change e.g. invalid use of undefined will be easy to catch in prepBindings (stuff like .where('id', undefined)).

@elhigu elhigu force-pushed the elhigu:evaluate-multi-insert-undefined-key-replace-already-in-query-compiler branch from 99a375e to 87a39e4 May 12, 2016

@elhigu elhigu force-pushed the elhigu:evaluate-multi-insert-undefined-key-replace-already-in-query-compiler branch from 87a39e4 to c935b58 May 12, 2016

@elhigu

This comment has been minimized.

Copy link
Collaborator Author

elhigu commented May 12, 2016

Fixes e.g. Error: Cannot find module 'pg-native'

@elhigu elhigu added the bug label May 12, 2016

@elhigu

This comment has been minimized.

Copy link
Collaborator Author

elhigu commented May 12, 2016

Could @wubuzz / @rhys-vdw check this out at some point... This could be released as a part of 0.11.2 maybe? I just did hit this again and had to downgrade back to 0.10 :|

@wubzz

This comment has been minimized.

Copy link
Collaborator

wubzz commented May 13, 2016

@elhigu I see nothing wrong with the code, 👍 .

I actually kind of prefer DEFAULT in the plain sql rather than a binding ? since technically it was never a used-submitted binding to begin with, so kudos to that. Looks good to me!

@elhigu elhigu merged commit 9bded93 into tgriesser:master May 13, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@elhigu elhigu deleted the elhigu:evaluate-multi-insert-undefined-key-replace-already-in-query-compiler branch May 13, 2016

@villelahdenvuo

This comment has been minimized.

Copy link
Contributor

villelahdenvuo commented on src/dialects/postgres/utils.js in 9114bdd May 19, 2016

@elhigu This caused #1423 Because the above if used to have || val === undefined

This comment has been minimized.

Copy link
Collaborator Author

elhigu replied May 19, 2016

Yep, I know. But having || val === undefined there is wrong way of handling this problem :) Pushing real fix in a moment. In the end I found that client.valueForUndefined to transacting client...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.