Skip to content

Commit

Permalink
Merge pull request #319 from microsoft/50-ci
Browse files Browse the repository at this point in the history
Fix get_constraints query for defaults
  • Loading branch information
mShan0 authored Dec 22, 2023
2 parents 70565fd + 7d55721 commit 47af010
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions mssql/introspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,15 +319,15 @@ def get_constraints(self, cursor, table_name):
# Record the details
constraints[constraint]['columns'].append(column)
# Now get DEFAULT constraint columns
cursor.execute(f"""
SELECT d.name AS constraint_name, pc.name AS column_name
FROM sys.default_constraints AS d
INNER JOIN sys.columns pc ON
d.parent_object_id = pc.object_id AND
d.parent_column_id = pc.column_id
cursor.execute("""
SELECT
[name],
COL_NAME([parent_object_id], [parent_column_id])
FROM
[sys].[default_constraints]
WHERE
type_desc = 'DEFAULT_CONSTRAINT'
""")
OBJECT_NAME([parent_object_id]) = %s
""", [table_name])
for constraint, column in cursor.fetchall():
# If we're the first column, make the record
if constraint not in constraints:
Expand Down

0 comments on commit 47af010

Please sign in to comment.