Skip to content

Commit

Permalink
Updating the primary key constraints to be present when the parser do…
Browse files Browse the repository at this point in the history
…esnt load the sql as intellij format
  • Loading branch information
Jacobbrewer1 committed Dec 3, 2024
1 parent 105e978 commit 7141802
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/models/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ func (t *Table) setPrimaryKey(con *ast.Constraint) {
t.PrimaryKey.Columns[i].InPrimaryKey = true
t.PrimaryKey.Columns[i].InUniqueKey = true
}

for _, col := range t.Columns {
for _, pk := range t.PrimaryKey.Columns {
if col.Name == pk.Name {
col.InPrimaryKey = true
col.InUniqueKey = true
col.Nullable = false
}
}
}
}

func (t *Table) addKey(con *ast.Constraint) {
Expand Down

0 comments on commit 7141802

Please sign in to comment.