We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 57c2b4a commit ee71b0aCopy full SHA for ee71b0a
1 file changed
src/schemaforge/parsers/sql_parser.py
@@ -228,13 +228,16 @@ def _parse_column_def(self, defn: str) -> Column | None:
228
# Parse constraints
229
constraints = " ".join(tokens[type_start+1:]) if type_start + 1 < len(tokens) else ""
230
231
+ is_pk = "PRIMARY KEY" in constraints.upper()
232
+ is_not_null = "NOT NULL" in constraints.upper()
233
+
234
col = Column(
235
name=col_name,
236
type=col_type,
237
type_args=type_args,
- nullable="NOT NULL" not in constraints.upper(),
- unique="UNIQUE" in constraints.upper(),
- primary_key="PRIMARY KEY" in constraints.upper(),
238
+ nullable=not (is_not_null or is_pk),
239
+ unique="UNIQUE" in constraints.upper() and not is_pk,
240
+ primary_key=is_pk,
241
)
242
243
# Extract default
0 commit comments