From 07219a2bc3024ea039befec7cf119f8b5dac50a0 Mon Sep 17 00:00:00 2001 From: zyzil Date: Mon, 27 Jun 2022 10:46:09 -0500 Subject: [PATCH] Merge upstream changes from wintersd Better handling of FLOAT and DECIMAL types, including fix for real README.md update for example config --- README.md | 1 + tap_mssql/__init__.py | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 670b3259..9e099c4f 100755 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ Create a config file containing the database connection credentials, e.g.: ```json { "host": "localhost", + "database": "db", "port": "3306", "user": "root", "password": "password", diff --git a/tap_mssql/__init__.py b/tap_mssql/__init__.py index a3479f11..fb52a83b 100755 --- a/tap_mssql/__init__.py +++ b/tap_mssql/__init__.py @@ -68,12 +68,13 @@ "smallint": 2, "mediumint": 3, "int": 4, - "real": 4, "bigint": 8, "timestamp": 8, } -FLOAT_TYPES = set(["float", "double", "money"]) +FLOAT_TYPES = set(["float", "double", "real"]) + +DECIMAL_TYPES = set(["decimal", "number", "money"]) DATETIME_TYPES = set( ["datetime", "datetime2", "date", "smalldatetime", "datetimeoffset"] @@ -110,9 +111,9 @@ def schema_for_column(c): elif data_type in FLOAT_TYPES: result.type = ["null", "number"] - result.multipleOf = 10 ** (0 - (c.numeric_scale or 6)) + result.multipleOf = 10 ** (0 - (c.numeric_scale or 17)) - elif data_type in ["decimal", "numeric"]: + elif data_type in DECIMAL_TYPES: result.type = ["null", "number"] result.multipleOf = 10 ** (0 - c.numeric_scale) return result