lqs / sqlingo

💥 A lightweight DSL & ORM which helps you to write SQL in Go.
MIT License
415 stars 28 forks source link

support prepared arguments #16

Open canuran opened 1 year ago

canuran commented 1 year ago
SELECT ...... WHERE "Order"."id" in (1,2,3) AND ("Order"."name" LIKE 'Can%' OR "Order"."price" > 15)

to

SELECT ...... WHERE "Order"."id" in (?,?,?) AND ("Order"."name" LIKE ? OR "Order"."price" > ?)

By the way, this is a very good project!

lqs commented 1 year ago

It's good to use prepared statements to improve performance, but the problem is with the "in" clause that requires the exact number of placeholders in the prepared statement. This leads to different prepared statements for various counts in the list. Any suggestions?

canuran commented 1 year ago

It's good to use prepared statements to improve performance, but the problem is with the "in" clause that requires the exact number of placeholders in the prepared statement. This leads to different prepared statements for various counts in the list. Any suggestions?

Not just for performance but also for safety. The number of parameters is fixed when executing.