Skip to content

Commit

Permalink
[Fix] Fix not null not being set on postgres deparser (#46)
Browse files Browse the repository at this point in the history
Since the field isNotNull on the object created by the pg_query deparser is not being set correctly, I got the isNotNull information by checking the whole object generated by the deparser.
  • Loading branch information
atedesch1 authored Jun 25, 2022
1 parent ce1a57f commit 16aa0cf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion drivers/postgres/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,16 @@ func (d *postgresDriver) parseColumn(columnDefinition *pg_query.ColumnDef) *doma
parameters["size"] = columnDefinition.TypeName.Typmods[0].GetAConst().Val.GetInteger().Ival
}

isNotNull := false
for _, constraint := range columnDefinition.Constraints {
if constraint.GetConstraint().GetContype().String() == "CONSTR_NOTNULL" {
isNotNull = true
}
}

return &domain.Column{
Datatype: datatype,
Parameters: parameters,
IsNotNull: columnDefinition.IsNotNull,
IsNotNull: isNotNull,
}
}

0 comments on commit 16aa0cf

Please sign in to comment.