From 7fd1ddaa5f42a45b390d546aa18720476b654fca Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Wed, 18 Feb 2015 23:43:27 +0100 Subject: [PATCH] Handle MS SQL columns of float types without scale, fix #177. The default for MS SQL float types is to only have a precision defined, as described in https://msdn.microsoft.com/en-us/library/ms173773.aspx, but the pgloader code didn't know what to do with a float without scale. --- src/sources/mssql/mssql-cast-rules.lisp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/sources/mssql/mssql-cast-rules.lisp b/src/sources/mssql/mssql-cast-rules.lisp index ba73eee..eee923e 100644 --- a/src/sources/mssql/mssql-cast-rules.lisp +++ b/src/sources/mssql/mssql-cast-rules.lisp @@ -84,9 +84,21 @@ (mssql-column-identity col)) "bigserial") - ((member type - '("decimal" "numeric" "float" "double" "real") - :test #'string=) + ((member type '("float" "real") :test #'string=) + ;; see https://msdn.microsoft.com/en-us/library/ms173773.aspx + (if (mssql-column-numeric-scale col) + (if (<= (mssql-column-numeric-scale col) 24) + "float" + "double precision") + + ;; no scale + (format nil "~a(~a,~a)" + type + (mssql-column-numeric-precision col) + (mssql-column-numeric-scale col)))) + + ((member type '("decimal" "numeric" ) :test #'string=) + ;; https://msdn.microsoft.com/en-us/library/ms187746.aspx (format nil "~a(~a,~a)" type (mssql-column-numeric-precision col)