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

Add Named Placeholders for Query Printout #1694

Open
deusaquilus opened this issue Nov 4, 2019 · 0 comments
Open

Add Named Placeholders for Query Printout #1694

deusaquilus opened this issue Nov 4, 2019 · 0 comments

Comments

@deusaquilus
Copy link
Collaborator

Version: (e.g. 3.4.8)
Module: (e.g. quill-sql)
Database: (e.g. mysql)

Right now, for the compile-time query printout, all lifted variables are question marks:

val ctx = new SqlMirrorContext(SQLServerDialect, SnakeCase)
import ctx._
case class Person(name:String, age:Long)
val nameValue = "Joe"
val ageValue = 22 
run(query[Person].filter(p => p.name == lift(nameValue) && p.age > lift(ageValue))).string
// SELECT p.name, p.age FROM person p WHERE p.name = ? AND p.age > ?

It would be much more useful to use either the name of the case-class/tuple variable

SELECT p.name, p.age FROM person p WHERE p.name = ${name} AND p.age > ${age}

...or the variable name that is being used

SELECT p.name, p.age FROM person p WHERE p.name = ${nameValue} AND p.age > ${ageValue}

The former is a better solution but it is very hard to do because Quill only tracks lifted variables by position. The latter option is simpler because ScalarValueLift already has the variable name which of course does not work if it's a compound statement but we could detect such a situation and have a fallback.

@getquill/maintainers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant