-
Notifications
You must be signed in to change notification settings - Fork 0
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 explicit casts #17
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sunil got a little test suite working with an in memory database. may be worth adding a test that fails than succeeds for this? I admit to not knowing the rules for this sort of cast in postgresql very well..
@@ -347,7 +347,7 @@ export class SQLFragment<RunResult = pg.QueryResult['rows'], Constraint = never> | |||
|
|||
} else if (typeof expression.cast === 'string') { | |||
result.values.push(expression.value); | |||
result.text += `CAST(${placeholder} AS "${expression.cast}")`; | |||
result.text += `CAST(${placeholder} AS ${expression.cast})`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I follow what removing the quotes fixes. Can you elucidate? Quickly checking in pgAdmin query tool seems like the quotes are indeed not needed, but also not harmful there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the quotes I was getting errors.. except when the value was "json." All other quoted type strings would fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't argue with empiricism!
This fixes jawj#180. @dmitri-anchorzero this could be of use in the new json subquery stuff when using zapatos.param()