Commit c8bf991
Handle convertPatternInExpr. (sqlc-dev#1088)
* Handle convertPatternInExpr.
This can be handled just by calling convert on the subquery, and it is
necessary for some kinds of queries.
Like the following, without this we don't pickup the parameter, and thus
can't handle the query at all:
select * from foo where field in (select substring(?, 1, seq) from seq_1_to_19)
* Add ast.In
This is used for queries like the following:
SELECT a, b from foo where foo.a in (select a from bar where bar.b = ?);
SELECT a, b from foo where foo.a in (?, ?);
SELECT a, b from foo where foo.a not in (?, ?);
SELECT a, b from foo where ? in (foo.a, foo.b);
The support is heavily based on that found in the fork found at:
https://github.com/xiazemin/sqlc.git
However it should be noted that this is not just a straight copy and
paste job, there are several pieces from that branch for features that
don't exist in the main sqlc repository, the sqlc repository has changed
a bit since the fork, and the fork version does not handle the latter
case at all.
* Adapt convertPatternInExpr to use ast.In
This is used for queries like the following:
SELECT a, b from foo where foo.a in (select a from bar where bar.b = ?);
SELECT a, b from foo where foo.a in (?, ?);
SELECT a, b from foo where foo.a not in (?, ?);
SELECT a, b from foo where ? in (foo.a, foo.b);
The support is heavily based on that found in the fork found at:
https://github.com/xiazemin/sqlc.git
However it should be noted that this is not just a straight copy and
paste job, there are several pieces from that branch for features that
don't exist in the main sqlc repository, the sqlc repository has changed
a bit since the fork, and the fork version does not handle the latter
case at all.
* Add test cases for convertPatternInExpr.
This covers all the cases I can think of, though if I missed some, it's
quite possible that they are broken in the code as well as absent in the
tests.
* Only check for duplicate c.id on query outputs.
That is, we want to deduplicate the same column from showing up multiple
times, and thus we want to avoid adding a suffix, when we are getting
the results from a query, however we most definitely do not want to do
this for query parameters.
Especially since the logic for handling this in the query parameters is
missing the deduplication, but also because the database itself expects
the same number of parameters as we have placeholders in the query.
* Make seen use fieldName instead of colName.
fieldName is after any mangilng to make it fit go variable standards,
and since that is the name that we are actually using, that is the name
that we should be checking for conflicts.
This only matters when we have multiple fields that differ only by
things that are changed when we are converting to the go variable
standards.
* Update test files for A_2 vs A.
This should now build a little better, now that we have fixed the
generator.
* Make seen use the pre-modification fieldName.
Oops, this fixes a bug introduced in
885bd3d.
* DefaultSchema support for ast.In.
Needed now that we're merging in master.
Co-authored-by: Zephaniah E. Loss-Cutler-Hull <warp@aehallh.com>
Co-authored-by: Kyle Conroy <kyle@conroy.org>1 parent c2dcd56 commit c8bf991
File tree
11 files changed
+375
-7
lines changed- internal
- codegen/golang
- compiler
- endtoend/testdata/pattern_in_expr/mysql
- go
- engine/dolphin
- sql
- astutils
- ast
11 files changed
+375
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
184 | | - | |
| 184 | + | |
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
| |||
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
228 | | - | |
| 228 | + | |
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
| |||
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
252 | | - | |
| 252 | + | |
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
| |||
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
| 262 | + | |
262 | 263 | | |
263 | 264 | | |
264 | 265 | | |
265 | | - | |
| 266 | + | |
266 | 267 | | |
267 | | - | |
| 268 | + | |
268 | 269 | | |
269 | 270 | | |
270 | 271 | | |
| |||
284 | 285 | | |
285 | 286 | | |
286 | 287 | | |
287 | | - | |
| 288 | + | |
288 | 289 | | |
| 290 | + | |
289 | 291 | | |
290 | 292 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
145 | 164 | | |
146 | 165 | | |
147 | 166 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
373 | 471 | | |
374 | 472 | | |
375 | 473 | | |
| |||
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: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 127 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
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
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 | + | |
0 commit comments