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
why are select, order by, and group by $ escaped #35
Comments
This package uses Why do you need to use |
I lost an hour or so on this issue because |
Can you please show me some code? I still don't get your point. |
So for example, I cannot create these kind of queries: sqlbuilder.DefaultFlavor = sqlbuilder.PostgreSQL
sb := sqlbuilder.NewSelectBuilder()
sb.Select("id", fmt.Sprintf("someFunc(some_col, %s)", sb.Var("bar")))
sb.From("user")
sb.Where("status = " + sb.Var("foo"))
sql, args := sb.Build()
fmt.Println(sql)
fmt.Println(args) The output is:
As you can see, |
Or a more realistic example, where I want to find users with 'foo' in their name but sort the users whose name starts with 'foo' first: sqlbuilder.DefaultFlavor = sqlbuilder.PostgreSQL
sb := sqlbuilder.NewSelectBuilder()
foo := sb.Var("foo")
sb.Select("id")
sb.From("user")
sb.Where("name ~* " + foo)
sb.OrderBy(fmt.Sprintf("name ~* '^' || %s DESC", foo)) // DESC here because BOOL is sorted FALSE, TRUE
sql, args := sb.Build()
fmt.Println(sql)
fmt.Println(args) Prints
I understand now why this happens, but it's not desired I think, not sure how to fix this without introducing breaking changes. |
OK. I get it. I wasn't aware of your use cases. I can fix it soon. |
Fix #35. do not escape cols by default.
Is there any particular reason for this? Is there a workaround to use sub-expressions with positional arguments ($1, $2, etc. obtained using
.Var()
) in these positions?The text was updated successfully, but these errors were encountered: