-
Notifications
You must be signed in to change notification settings - Fork 540
Bind arguments with SqlBinaryExpr #4604
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
Conversation
9efa0b5
to
120ba4f
Compare
46a9b47
to
9c8a9e3
Compare
811d0d1
to
39aa044
Compare
373eaf0
to
cee71c7
Compare
Can you please also add a test with custom Kotlin types, as you mentioned in your summary, |
fixes sqldelight#4504 Try and lookup the parent SqlColumnExpr to get the type of the column
e.g there are two different parameter argument types SELECT CAST(:factor1 AS NUMERIC(10, 2)) * CAST(:factor2 AS INTEGER) - 10.5
Use SqlCastExpr tyoe or use SqlColumExpr to get column type Add Tests for Bind argument when used with CAST and Binary Expression
to streamline checks for CAST,
Arithmetic test case
BindArgTest for Instant using binary expressions
cee71c7
to
e33a8a4
Compare
🥼 Added tests for custom type Instant also see other 🥨 #4657 that adds temporal support to binary expressions |
Nice, but sorry, I mean integration tests, can you just copy the existing tests to the integration tests too? Thank you! |
@hfhbd ❓Do o you mean add atleast some docker integration-postgrsql tests or in the sqdelight-compiler integration tests. |
Yes, just in case. |
Test with adapter implementation and Instant types
Ok - have added integration tests |
fixes #4504
🤾 This PR is just to try out and see if any quick fixes
Try and lookup the parent
SqlColumnExpr
to get the type of the columnOnly the parent column can tell us what the type actually is declared as e.g Instant
Currently the tests pass and local snapshot works with cases
📓 The user will be required to implement and provide a ColumnAdapter for Instant to LocalDateTime, so the generated code would look like this e.g
CAST doesn't work with SqlBinaryExpr
In this contrived example, CAST doesn't force
factor
to be an INTEGER - the inferred type is REAL as the literal expression is chosen for the bind parameter type. Of course, the column result type is REALShould generate
bindLong
notbindDouble
Also cases of multiple CAST with bindArgs of different types