Skip to content

Commit 686bd8b

Browse files
committed
1 parent f43e744 commit 686bd8b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

pysimplesql/pysimplesql.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5729,10 +5729,12 @@ def cast(self, value: any) -> any:
57295729
elif domain == "DATE":
57305730
try:
57315731
value = datetime.strptime(value, "%Y-%m-%d").date()
5732-
except TypeError:
5732+
# TODO: ValueError for sqlserver returns date(): 2023-04-27 15:31:13.170000
5733+
except (TypeError, ValueError) as e:
57335734
logger.debug(
57345735
f"Unable to cast {value} to a datetime.date object. "
5735-
f"Casting to string instead."
5736+
f"Casting to string instead. "
5737+
f"{e=}"
57365738
)
57375739
value = str(value)
57385740

@@ -7607,7 +7609,16 @@ def column_info(self, table):
76077609
name = row["COLUMN_NAME"]
76087610
domain = row["DATA_TYPE"].upper()
76097611
notnull = row["IS_NULLABLE"] == "NO"
7610-
default = row["COLUMN_DEFAULT"]
7612+
if row["COLUMN_DEFAULT"]:
7613+
col_default = row["COLUMN_DEFAULT"]
7614+
if (col_default.startswith("('") and col_default.endswith("')")) or (
7615+
col_default.startswith('("') and col_default.endswith('")')
7616+
):
7617+
default = col_default[2:-2]
7618+
else:
7619+
default = col_default[1:-1]
7620+
else:
7621+
default = None
76117622
pk = name in pk_columns
76127623
col_info.append(
76137624
Column(

0 commit comments

Comments
 (0)