Skip to content

Commit

Permalink
Add default support for MSSQL auto-incrementing bigint and smallint (#…
Browse files Browse the repository at this point in the history
…1435)

* Add default support for MSSQL auto-incrementing bigint and smallint

* Update list-all-columns.sql

Add support for sysdatetimeoffset defaults

* Update mssql-cast-rules.lisp

Correct bigint cast
  • Loading branch information
justinfalk authored Oct 18, 2022
1 parent 759777a commit 6d73667
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/sources/mssql/mssql-cast-rules.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@

(:source (:type "int" :auto-increment t)
:target (:type "bigserial" :drop-default t))

(:source (:type "bigint" :auto-increment t)
:target (:type "bigserial"))

(:source (:type "smallint" :auto-increment t)
:target (:type "smallserial"))

(:source (:type "tinyint") :target (:type "smallint"))

Expand Down
2 changes: 2 additions & 0 deletions src/sources/mssql/sql/list-all-columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
WHEN SUBSTRING(c.COLUMN_DEFAULT,3,len(c.COLUMN_DEFAULT)-4) = 'newid()' THEN 'GENERATE_UUID'
WHEN SUBSTRING(c.COLUMN_DEFAULT,3,len(c.COLUMN_DEFAULT)-4) LIKE 'convert(%varchar%,getdate(),%)' THEN 'today'
WHEN SUBSTRING(c.COLUMN_DEFAULT,3,len(c.COLUMN_DEFAULT)-4) = 'getdate()' THEN 'CURRENT_TIMESTAMP'
WHEN SUBSTRING(c.COLUMN_DEFAULT,3,len(c.COLUMN_DEFAULT)-4) = 'sysdatetimeoffset()' THEN 'CURRENT_TIMESTAMP'
WHEN SUBSTRING(c.COLUMN_DEFAULT,3,len(c.COLUMN_DEFAULT)-4) LIKE '''%''' THEN SUBSTRING(c.COLUMN_DEFAULT,4,len(c.COLUMN_DEFAULT)-6)
ELSE SUBSTRING(c.COLUMN_DEFAULT,3,len(c.COLUMN_DEFAULT)-4)
END
Expand All @@ -22,6 +23,7 @@
WHEN SUBSTRING(c.COLUMN_DEFAULT,2,len(c.COLUMN_DEFAULT)-2) = 'newid()' THEN 'GENERATE_UUID'
WHEN SUBSTRING(c.COLUMN_DEFAULT,2,len(c.COLUMN_DEFAULT)-2) LIKE 'convert(%varchar%,getdate(),%)' THEN 'today'
WHEN SUBSTRING(c.COLUMN_DEFAULT,2,len(c.COLUMN_DEFAULT)-2) = 'getdate()' THEN 'CURRENT_TIMESTAMP'
WHEN SUBSTRING(c.COLUMN_DEFAULT,2,len(c.COLUMN_DEFAULT)-2) = 'sysdatetimeoffset()' THEN 'CURRENT_TIMESTAMP'
WHEN SUBSTRING(c.COLUMN_DEFAULT,2,len(c.COLUMN_DEFAULT)-2) LIKE '''%''' THEN SUBSTRING(c.COLUMN_DEFAULT,3,len(c.COLUMN_DEFAULT)-4)
ELSE SUBSTRING(c.COLUMN_DEFAULT,2,len(c.COLUMN_DEFAULT)-2)
END
Expand Down

0 comments on commit 6d73667

Please sign in to comment.