Commit ae36ce2
mysql: support to infer type of a duplicated arg (#615)
Fix for issue with WHERE clause in mysql (old parser) does not parse a
parameters type correctly in certain circumstances.
Such as:
`SELECT * FROM tablex WHERE (id = sqlc.arg(id) OR sqlc.arg(id) = 0);`
This type of statement is a simple way to conditionally filter by input
arg, so that you do not have to define a GetX and a GetXbyID.
(This is a simplified example)
In sqlc v1.4.0 the second id argument gets parsed and added to the
params struct as `ID_2` but is not given a type.
This causes compile-time errors.
Because of the way parameters are parsed and added to the params struct
this fix only works when you define the parameters as sqlc.args(x)
not with `?` or `:x`.
Co-authored-by: Jessica Bellon <10819486+JessTheBell@users.noreply.github.com>
Co-authored-by: Kyle Conroy <kyle@conroy.org>1 parent a53b27f commit ae36ce2
7 files changed
Lines changed: 130 additions & 0 deletions
File tree
- internal
- endtoend/testdata/mysql_dupl_param_name
- go
- mysql
Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
130 | 144 | | |
131 | 145 | | |
132 | 146 | | |
| |||
0 commit comments