From 77e11416a3d41569a2395145373aae717e32c9b4 Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Mon, 22 Dec 2014 11:04:01 +0100 Subject: [PATCH] Fix MS SQL protocol handling of bigint. Actually, fix pgloader not to depend on MS SQL specifics for bigints in the protocol. Depending on the protocol version in the driver's setup, MS SQL would send bigints either as floats on the wire, loosing range, or as something else entirely which values do not match with what's in the database actually. Here we just convert the values to NUMERIC by using a CAST expression directly in the query, so that the protocol only see NUMERIC and everyone is happy. Or should be. Let's try that. --- src/sources/mssql/mssql-schema.lisp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sources/mssql/mssql-schema.lisp b/src/sources/mssql/mssql-schema.lisp index fdebb34..d7bf721 100644 --- a/src/sources/mssql/mssql-schema.lisp +++ b/src/sources/mssql/mssql-schema.lisp @@ -298,6 +298,7 @@ ORDER BY CONSTRAINT_NAME, KCU1.ORDINAL_POSITION Mostly we just use the name, and make try to avoid parsing dates." (case (intern (string-upcase type) "KEYWORD") (:datetime (format nil "convert(varchar, [~a], 126)" name)) + (:bigint (format nil "cast([~a] as numeric)" name)) (t (format nil "[~a]" name)))) (defun get-column-list (columns)