-
Notifications
You must be signed in to change notification settings - Fork 50
Open
Description
Let's say we use comments to group sql queries
Example
-- file user.sql
--- UPDATE QUERIES ---
--name: EmailUpdate
UPDATE users SET email = $1 where user_id = $2
--name: LevelUpdate
UPDATE users SET level = $1 where user_id = $2
--- REPORTS ---
...
In current implementation --- REPORTS--- comment belongs to LevelUpdate query. Problem is when LevelUpdate is not complete and we update the query on the program side. Let's imagine t hat we have the following:
--name: LevelUpdate
UPDATE users SET level = $1 where user_id IN
and in the application:
q := queries.LevelUpdate + fmt.Sprintf(" (%s)", strings.Join(userIDs, ","))
This will fail: ERROR: syntax error at end of input (SQLSTATE 42601) - because queries.LevelUpdate is finishing with a comment. I know that we can bind here the sqlx solution, however this is just a simple example.
We need a phrase to end the query, eg: --end
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels