codegen: CreateUpdateDelete test no longer creates an "Update" block if there's no updateable fields

This commit is contained in:
2026-09-19 21:36:31 -07:00
parent f98f8416e8
commit 6cf0b66dd5
4 changed files with 99 additions and 57 deletions

View File

@@ -76,3 +76,21 @@ func (t Table) HasSoftDelete() bool {
}
return hasIsDeleted && hasDeletedAt
}
// GetUpdateableColumns returns the columns that should be written to by an "update" operation.
func (t Table) GetUpdateableColumns() (ret []Column) {
hasCreatedAt, _ := t.HasAutoTimestamps()
for _, col := range t.Columns {
if col.Name == "rowid" || col.IsPrimaryKey {
continue // Rowid / primary key is never updateable
}
if col.Name == "created_at" && hasCreatedAt {
continue // Update shouldn't write `created_at`
}
if t.HasSoftDelete() && (col.Name == "is_deleted" || col.Name == "deleted_at") {
continue // Soft-delete state is managed by SoftDeleteXyz(), not by updates
}
ret = append(ret, col)
}
return
}