-
Notifications
You must be signed in to change notification settings - Fork 107
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
Bugfix rollup: Fix issue with extra characters in generated SQL; Fix ToAliasReference for already referenced values; Fix Alias/Reference for Maybe Entity #191
Conversation
…ues in mysql. Extra backticks in value reference names
@parsonsmatt the code that triggered this bug was
unsafeSqlFunction isn't wrapping in parens at all but unsafeSqlBinOp was. Not sure if we should just Never add parens or if this safer check is better. Either way, bumped and were gonna be relying on this commit at work. |
…rence by its new alias source
Found another bug while working on this query. Was doing a SubQuery join on a Union and got errors where the union alias ( |
@@ -767,6 +771,7 @@ instance ( ToAlias a | |||
type family ToAliasReferenceT a where | |||
ToAliasReferenceT (SqlExpr (Value a)) = SqlExpr (Value a) | |||
ToAliasReferenceT (SqlExpr (Entity a)) = SqlExpr (Entity a) | |||
ToAliasReferenceT (SqlExpr (Maybe (Entity a))) = SqlExpr (Maybe (Entity a)) |
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.
This is a very unrelated question, but why do both ToAliasT
and ToAliasReferenceT
exist? They seem to do the same thing (?)
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.
They might be able to be merged but it's not clear to me that they will always be the same. They initially started as associated type families in their respective classes. Semantically they are different though, an alias is something like "value as alias" where an alias reference is like "q.v".
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.
Asked a question re the ticks
Looks great! Mind getting the conflicts resolved?
…e general solution than removeTicks
let | ||
valueToFunctionArgParens v = | ||
case v of | ||
ERaw p f -> first (parensM p) (f info) | ||
EAliasedValue i _ -> aliasedValueIdentToRawSql i info | ||
EValueReference i i' -> valueReferenceToRawSql i i' info | ||
ECompositeKey _ -> throw (CompositeKeyErr SqlFunctionError) | ||
(argsTLB, argsVals) = | ||
uncommas' $ map valueToFunctionArgParens $ toArgList arg |
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.
fix #201
@parsonsmatt I fixed #201 while while resolving the conflicts. Seemed better to fix it in one PR and its not much more code. See the commented code for the fix. Additionally removed the other ERaw lambda that was left but it uses the same code that unsafeSqlFunction uses |
in_
was generating invalid mysql statements by double wrapping value lists. This existed before 3.3.3.1. Also fixed an issue with the generated value names in subqueries getting "`"s erroneously added for each nestingBefore submitting your PR, check that you've:
After submitting your PR: