Skip to content

cmd/generate-database/db: Fix create/update with composite keys#2616

Merged
stgraber merged 1 commit intolxc:mainfrom
masnax:db-nesting
Nov 4, 2025
Merged

cmd/generate-database/db: Fix create/update with composite keys#2616
stgraber merged 1 commit intolxc:mainfrom
masnax:db-nesting

Conversation

@masnax
Copy link
Copy Markdown
Contributor

@masnax masnax commented Nov 4, 2025

Fixes an edge-case where more parameters were being created than could be populated with struct field values.

Example:

type StructA struct { // maps to table_a
  TableBName string `db:"join=table_b.name"`
  TableCName string `db:"join=table_c.name"`
}
  • table_a has columns table_b_id (joins to table_b) and table_c_id (joins to table_c)
  • table_b has a composite key name and table_c_id (joins to table_c)

When generating statements for table_a, we shouldn't need 2 parameters for table_c_id, we just need one and we can re-use the value we got for the other column.

@masnax masnax requested a review from stgraber as a code owner November 4, 2025 22:00
@stgraber stgraber merged commit f024563 into lxc:main Nov 4, 2025
36 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants