Skip to content

Commit

Permalink
add additional t-sql datetime mappings (datacontract#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryancollingwood authored May 5, 2024
1 parent 01b1f0d commit 2e2f61d
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions datacontract/imports/sql_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,31 @@ def map_type_from_sql(sql_type: str):
if sql_type is None:
return None

if sql_type.lower().startswith("varchar"):
sql_type_normed = sql_type.lower().strip()

if sql_type_normed.startswith("varchar"):
return "varchar"
if sql_type.lower().startswith("string"):
elif sql_type_normed.startswith("string"):
return "string"
if sql_type.lower().startswith("text"):
elif sql_type_normed.startswith("text"):
return "text"
elif sql_type.lower().startswith("int"):
elif sql_type_normed.startswith("int"):
return "integer"
elif sql_type.lower().startswith("float"):
elif sql_type_normed.startswith("float"):
return "float"
elif sql_type.lower().startswith("bool"):
elif sql_type_normed.startswith("bool"):
return "boolean"
elif sql_type.lower().startswith("timestamp"):
elif sql_type_normed.startswith("timestamp"):
return "timestamp"
elif sql_type_normed == "date":
return "date"
elif sql_type_normed == "smalldatetime":
return "timestamp_ntz"
elif sql_type_normed == "datetime":
return "timestamp_ntz"
elif sql_type_normed == "datetime2":
return "timestamp_ntz"
elif sql_type_normed == "datetimeoffset":
return "timestamp_tz"
else:
return "variant"

0 comments on commit 2e2f61d

Please sign in to comment.