From 7753d0610a3db7f13dc5a4375b565ed0cbf43827 Mon Sep 17 00:00:00 2001 From: conorreid Date: Fri, 21 Jun 2019 11:45:44 -0400 Subject: [PATCH 1/3] bigint check --- dataset/types.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dataset/types.py b/dataset/types.py index 20606ce..6cb3dba 100644 --- a/dataset/types.py +++ b/dataset/types.py @@ -27,7 +27,10 @@ class Types(object): if isinstance(sample, bool): return cls.boolean elif isinstance(sample, int): - return cls.integer + if sample > 2147483647 or sample < -2147483648: + return cls.bigint + else: + return cls.integer elif isinstance(sample, float): return cls.float elif isinstance(sample, datetime): From 96f57f161a2e21062a6827abc93a04bd6eba0ead Mon Sep 17 00:00:00 2001 From: conorreid Date: Fri, 21 Jun 2019 11:49:01 -0400 Subject: [PATCH 2/3] added tests for big int vs integer check --- test/test_dataset.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/test_dataset.py b/test/test_dataset.py index 99521ce..1e73918 100644 --- a/test/test_dataset.py +++ b/test/test_dataset.py @@ -6,7 +6,7 @@ import os import unittest from datetime import datetime -from sqlalchemy import FLOAT, INTEGER, TEXT +from sqlalchemy import FLOAT, INTEGER, TEXT, BIGINT from sqlalchemy.exc import IntegrityError, SQLAlchemyError, ArgumentError from dataset import connect @@ -441,6 +441,14 @@ class TableTestCase(unittest.TestCase): assert 'pippo' in tbl.table.c, tbl.table.c assert isinstance(tbl.table.c['pippo'].type, TEXT), \ tbl.table.c['pippo'].type + tbl.create_column_by_example('bigbar', 11111111111) + assert 'bigbar' in tbl.table.c, tbl.table.c + assert isinstance(tbl.table.c['bigbar'].type, BIGINT), \ + tbl.table.c['bigbar'].type + tbl.create_column_by_example('littlebar', -11111111111) + assert 'littlebar' in tbl.table.c, tbl.table.c + assert isinstance(tbl.table.c['littlebar'].type, BIGINT), \ + tbl.table.c['littlebar'].type def test_key_order(self): res = self.db.query('SELECT temperature, place FROM weather LIMIT 1') From 8409c40645314d50e66e039cc90b3e32c4499c38 Mon Sep 17 00:00:00 2001 From: conorreid Date: Sat, 13 Jul 2019 10:42:20 -0400 Subject: [PATCH 3/3] switch all ints to bigints --- dataset/types.py | 5 +---- test/test_dataset.py | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/dataset/types.py b/dataset/types.py index 6cb3dba..46f5550 100644 --- a/dataset/types.py +++ b/dataset/types.py @@ -27,10 +27,7 @@ class Types(object): if isinstance(sample, bool): return cls.boolean elif isinstance(sample, int): - if sample > 2147483647 or sample < -2147483648: - return cls.bigint - else: - return cls.integer + return cls.bigint elif isinstance(sample, float): return cls.float elif isinstance(sample, datetime): diff --git a/test/test_dataset.py b/test/test_dataset.py index 1e73918..22530c9 100644 --- a/test/test_dataset.py +++ b/test/test_dataset.py @@ -6,7 +6,7 @@ import os import unittest from datetime import datetime -from sqlalchemy import FLOAT, INTEGER, TEXT, BIGINT +from sqlalchemy import FLOAT, TEXT, BIGINT from sqlalchemy.exc import IntegrityError, SQLAlchemyError, ArgumentError from dataset import connect @@ -435,7 +435,7 @@ class TableTestCase(unittest.TestCase): tbl.table.c['bar'].type tbl.create_column_by_example('bar', 1) assert 'bar' in tbl.table.c, tbl.table.c - assert isinstance(tbl.table.c['bar'].type, INTEGER), \ + assert isinstance(tbl.table.c['bar'].type, BIGINT), \ tbl.table.c['bar'].type tbl.create_column_by_example('pippo', 'test') assert 'pippo' in tbl.table.c, tbl.table.c