fix: column field singularization, duplicate parameter names, sequence args typing#164
fix: column field singularization, duplicate parameter names, sequence args typing#164Mic92 wants to merge 4 commits into
Conversation
Field names went through the same inflection as table names: a query selecting an "outputs" column got an "output" field that no longer matched the database column. The duplicate-column suffix was also computed but never applied, so two same-named selected columns produced a class with duplicate fields. Use the column name as-is, plus the duplicate suffix. Embedded fields stay singularized: they hold one row of the joined table, not a column.
A query mixing a positional reference ($2) with a same-named sqlc.arg() emitted two function parameters with the same name, which is not valid Python.
asyncpg passes array parameters (e.g. text[]) as Python sequences; :many queries taking them failed type checking against the QueryResults *args annotation.
Plural column names stay as-is, duplicate selected columns get suffixed fields, and a positional + same-named sqlc.arg() mix generates distinct parameters. Outputs regenerated with the rebuilt plugin.
|
Warning Review limit reached
More reviews will be available in 58 minutes and 5 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (64)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
45d0a68 to
3a5fbeb
Compare
I hit three codegen bugs while using the plugin with asyncpg, fixed in separate commits:
Field names get singularized. My schema has an
outputsjsonb column and the generated row classes called the fieldoutput, so it no longer matched the column. Looks like the table-name inflection was accidentally applied to column names too. While fixing this I noticed the duplicate-column suffix was computed but never applied to the emitted name, so something likegenerated a class with two identical fields. Both fixed; embed fields keep the singular naming since those represent a row, not a column.
Duplicate function parameters. I had a query using
$2in one place andsqlc.arg(status)in another, and got:Now the second one becomes
status_2.QueryResultsArgsType doesn't allow sequences, but asyncpg takes array parameters (
text[]etc.) as Python sequences, so every:manyquery with an array param fails pyright/mypy. Addedcollections.abc.Sequence[typing.Any]to the union.Heads up on the first fix: anyone with plural column names gets renamed fields after this (they get the actual column names). That's the point of the fix, but it will show up as a diff in regenerated code.