Open robert-zaremba opened 8 years ago
Good question, a simpler solution would be strip all the comments when parsing the file, so you don't have to write specific annotations. Does that make sense to you?
Yes, this is a good idea.
emmmm, is there a risk of sql-injection?
I know that we can bind here the sqlx solution,
sqlx.In
maybe better.
i have many sql in dot.sql, i want using comment to splite these lines, but i can't using ----------------
or /**************/
comment must start as -- name:
now. example:
-- name: ----------------------------------------
-- this is general sql comments
--------------------------------------------------
-- name: -------- update sql for files ----------
refer to my current dot.sql
, it’s a bit embarrassing to write comments like this, I hope it can be improved.
https://github.com/vagra/botools/blob/c6ab0c0a5e4ccba302caf261100cf9cc890cf6f4/dot.sql
Let's say we use comments to group sql queries
Example
In current implementation
--- REPORTS---
comment belongs toLevelUpdate
query. Problem is whenLevelUpdate
is not complete and we update the query on the program side. Let's imagine t hat we have the following:and in the application:
This will fail:
ERROR: syntax error at end of input (SQLSTATE 42601)
- becausequeries.LevelUpdate
is finishing with a comment. I know that we can bind here thesqlx
solution, however this is just a simple example.We need a phrase to end the query, eg:
--end