MSSQL: fix typmod conversion for "max" typemods (#573)

The previous commit makes it possible to convert typemods for various
text types. In MSSQL it's possible to create a column like varchar(max).
Internally this is reported as varchar(-1) which results in a CREATE
TABLE statement that contains e.g. varchar(-1).

This patch drops the typemod if it's -1 (max).

It's based on Dimitris patch slightly modified by myself.
This commit is contained in:
Adrian Vondendriesch 2017-06-09 16:12:17 +02:00 committed by Dimitri Fontaine
parent d0c273a512
commit 1f3659941e

View File

@ -106,11 +106,16 @@
type
(mssql-column-numeric-precision col)
(or (mssql-column-numeric-scale col) 0)))))
((member type '("char" "nchar" "varchar" "nvarchar" "binary") :test #'string=)
((member type '("char" "nchar" "varchar" "nvarchar" "binary")
:test #'string=)
;; the user might have a CAST rule with keep typemod, so we need
;; to deal with character-maximum-length for now
(format nil "~a(~a)"
type (mssql-column-character-maximum-length col)))
(if (= -1 (mssql-column-character-maximum-length col))
type
(format nil "~a(~a)"
type (mssql-column-character-maximum-length col))))
(t type))))