Skip to content

Commit 13bae9a

Browse files
committed
Add type compat for 4.0 and update CrateDB used in tests to 4.0.2
1 parent 41b0c4a commit 13bae9a

File tree

8 files changed

+40
-23
lines changed

8 files changed

+40
-23
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ Changes for crate
55
Unreleased
66
==========
77

8+
- Extended the type mapping for SQLAlchemy for the upcoming type name changes
9+
in CrateDB 4.0.
10+
811
- Added support for Python 3.7 and made that version the recommended one.
912

1013
2019/03/05 0.23.0

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ jobs:
3636
3737
- script: |
3838
bin/flake8
39-
bin/coverage run bin/test -vv1
39+
JAVA_HOME=$JAVA_HOME_12_X64 bin/coverage run bin/test -vv1
4040
displayName: 'test'

src/crate/client/doctests/client.txt

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -178,29 +178,31 @@ supported, all other fields are 'None'::
178178
>>> cursor.execute("SELECT * FROM locations order by name")
179179
>>> result = cursor.fetchone()
180180
>>> pprint(result)
181-
[1373932800000,
181+
['Aldebaran',
182+
1373932800000,
182183
None,
183-
u'Max Quordlepleen claims that the only thing left ...',
184184
None,
185185
None,
186-
u'Star System',
187-
u'Aldebaran',
186+
'Star System',
188187
None,
189-
None,
190-
1]
188+
1,
189+
'Max Quordlepleen claims that the only thing left after the end of the '
190+
'Universe will be the sweets trolley and a fine selection of Aldebaran '
191+
'liqueurs.',
192+
None]
191193

192194
>>> result = cursor.description
193195
>>> pprint(result)
194-
((u'date', None, None, None, None, None, None),
195-
(u'datetime', None, None, None, None, None, None),
196-
(u'description', None, None, None, None, None, None),
197-
(u'details', None, None, None, None, None, None),
198-
(u'flag', None, None, None, None, None, None),
199-
(u'kind', None, None, None, None, None, None),
200-
(u'name', None, None, None, None, None, None),
201-
(u'nullable_date', None, None, None, None, None, None),
202-
(u'nullable_datetime', None, None, None, None, None, None),
203-
(u'position', None, None, None, None, None, None))
196+
(('name', None, None, None, None, None, None),
197+
('date', None, None, None, None, None, None),
198+
('datetime', None, None, None, None, None, None),
199+
('nullable_datetime', None, None, None, None, None, None),
200+
('nullable_date', None, None, None, None, None, None),
201+
('kind', None, None, None, None, None, None),
202+
('flag', None, None, None, None, None, None),
203+
('position', None, None, None, None, None, None),
204+
('description', None, None, None, None, None, None),
205+
('details', None, None, None, None, None, None))
204206

205207
Closing the Cursor
206208
==================

src/crate/client/doctests/sqlalchemy.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,9 @@ In order to create all missing tables the ``create_all`` method can be used::
308308
... "where table_name = 'departments' "
309309
... "order by column_name")
310310
>>> pprint([str(r) for r in conn.execute(stmt)])
311-
["('departments', 'code', 1, 'integer')",
312-
"('departments', 'id', 2, 'string')",
313-
"('departments', 'name', 3, 'string')"]
311+
["('departments', 'code', 3, 'integer')",
312+
"('departments', 'id', 1, 'text')",
313+
"('departments', 'name', 2, 'text')"]
314314

315315
Delete Tables
316316
-------------

src/crate/client/sqlalchemy/dialect.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,38 @@
3939
TYPES_MAP = {
4040
"boolean": sqltypes.Boolean,
4141
"short": sqltypes.SmallInteger,
42+
"smallint": sqltypes.SmallInteger,
4243
"timestamp": sqltypes.TIMESTAMP,
44+
"timestamp with time zone": sqltypes.TIMESTAMP,
4345
"object": Object,
4446
"integer": sqltypes.Integer,
4547
"long": sqltypes.NUMERIC,
48+
"bigint": sqltypes.NUMERIC,
4649
"double": sqltypes.DECIMAL,
50+
"double precision": sqltypes.DECIMAL,
4751
"object_array": ObjectArray,
4852
"float": sqltypes.Float,
49-
"string": sqltypes.String
53+
"real": sqltypes.Float,
54+
"string": sqltypes.String,
55+
"text": sqltypes.String
5056
}
5157
try:
5258
# SQLAlchemy >= 1.1
5359
from sqlalchemy.types import ARRAY
5460
TYPES_MAP["integer_array"] = ARRAY(sqltypes.Integer)
5561
TYPES_MAP["boolean_array"] = ARRAY(sqltypes.Boolean)
5662
TYPES_MAP["short_array"] = ARRAY(sqltypes.SmallInteger)
63+
TYPES_MAP["smallint_array"] = ARRAY(sqltypes.SmallInteger)
5764
TYPES_MAP["timestamp_array"] = ARRAY(sqltypes.TIMESTAMP)
65+
TYPES_MAP["timestamp with time zone_array"] = ARRAY(sqltypes.TIMESTAMP)
5866
TYPES_MAP["long_array"] = ARRAY(sqltypes.NUMERIC)
67+
TYPES_MAP["bigint_array"] = ARRAY(sqltypes.NUMERIC)
5968
TYPES_MAP["double_array"] = ARRAY(sqltypes.DECIMAL)
69+
TYPES_MAP["double precision_array"] = ARRAY(sqltypes.DECIMAL)
6070
TYPES_MAP["float_array"] = ARRAY(sqltypes.Float)
71+
TYPES_MAP["real_array"] = ARRAY(sqltypes.Float)
6172
TYPES_MAP["string_array"] = ARRAY(sqltypes.String)
73+
TYPES_MAP["text_array"] = ARRAY(sqltypes.String)
6274
except Exception:
6375
pass
6476

src/crate/client/tests.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ def setUpMocked(test):
9999

100100
settings = {
101101
'udc.enabled': 'false',
102-
'license.enterprise': 'true',
103102
'lang.js.enabled': 'true',
104103
'auth.host_based.enabled': 'true',
105104
'auth.host_based.config.0.user': 'crate',

src/crate/testing/layer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ def __init__(self,
222222
self.verbose = verbose
223223
self.env = env or {}
224224
self.env.setdefault('CRATE_USE_IPV4', 'true')
225+
self.env.setdefault('JAVA_HOME', os.environ.get('JAVA_HOME'))
225226
self._stdout_consumers = []
226227
self.conn_pool = urllib3.PoolManager(num_pools=1)
227228

versions.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
crate_server = 3.2.5
2+
crate_server = 4.0.2
33

44
flake8 = 2.5.1
55
mccabe = 0.3.1

0 commit comments

Comments
 (0)