sqlc-dev / sqlc

Generate type-safe code from SQL
https://sqlc.dev
MIT License
13.59k stars 812 forks source link

Field order changed in sqlc v1.27 breaking sqlc-gen-python #3541

Open kevinvalk opened 3 months ago

kevinvalk commented 3 months ago

Version

1.27.0

What happened?

In Python the generated code requires to be ordered in a certain way (fields with defaults at the end). This was taken care by the following code in the sqlc-gen-python plugin

https://github.com/sqlc-dev/sqlc-gen-python/blob/3d5cd342d23ae143ed892170ffecda20ff9a1958/internal/gen.go#L1088-L1091

Between version 1.26.0 and 1.27.0, something was changed that broke that sorting. Now, fields are not ordered correctly anymore and in the case of Python, the generated files will break Python.

kyleconroy commented 3 months ago

Do you have a specific example that worked in 1.26.0 and fails in 1.27.0? It would help to have an exact case to understand what broke.

kevinvalk commented 3 months ago

Do you have a specific example that worked in 1.26.0 and fails in 1.27.0? It would help to have an exact case to understand what broke.

Will create a minimal example (probably early next week...).