crate 0.35.1__py2.py3-none-any.whl → 1.0.0.dev0__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. crate/client/__init__.py +1 -1
  2. crate/testing/test_datetime_old.py +90 -0
  3. crate-1.0.0.dev0-py3.11-nspkg.pth +1 -0
  4. {crate-0.35.1.dist-info → crate-1.0.0.dev0.dist-info}/METADATA +15 -19
  5. crate-1.0.0.dev0.dist-info/RECORD +26 -0
  6. {crate-0.35.1.dist-info → crate-1.0.0.dev0.dist-info}/WHEEL +1 -1
  7. crate/client/sqlalchemy/__init__.py +0 -50
  8. crate/client/sqlalchemy/compat/__init__.py +0 -0
  9. crate/client/sqlalchemy/compat/api13.py +0 -156
  10. crate/client/sqlalchemy/compat/core10.py +0 -264
  11. crate/client/sqlalchemy/compat/core14.py +0 -359
  12. crate/client/sqlalchemy/compat/core20.py +0 -447
  13. crate/client/sqlalchemy/compiler.py +0 -318
  14. crate/client/sqlalchemy/dialect.py +0 -369
  15. crate/client/sqlalchemy/predicates/__init__.py +0 -99
  16. crate/client/sqlalchemy/sa_version.py +0 -28
  17. crate/client/sqlalchemy/support.py +0 -62
  18. crate/client/sqlalchemy/tests/__init__.py +0 -59
  19. crate/client/sqlalchemy/tests/array_test.py +0 -111
  20. crate/client/sqlalchemy/tests/bulk_test.py +0 -256
  21. crate/client/sqlalchemy/tests/compiler_test.py +0 -434
  22. crate/client/sqlalchemy/tests/connection_test.py +0 -129
  23. crate/client/sqlalchemy/tests/create_table_test.py +0 -313
  24. crate/client/sqlalchemy/tests/datetime_test.py +0 -90
  25. crate/client/sqlalchemy/tests/dialect_test.py +0 -156
  26. crate/client/sqlalchemy/tests/dict_test.py +0 -460
  27. crate/client/sqlalchemy/tests/function_test.py +0 -47
  28. crate/client/sqlalchemy/tests/insert_from_select_test.py +0 -85
  29. crate/client/sqlalchemy/tests/match_test.py +0 -137
  30. crate/client/sqlalchemy/tests/query_caching.py +0 -143
  31. crate/client/sqlalchemy/tests/update_test.py +0 -115
  32. crate/client/sqlalchemy/tests/warnings_test.py +0 -64
  33. crate/client/sqlalchemy/types.py +0 -277
  34. crate/client/tests.py +0 -416
  35. crate/testing/tests.py +0 -34
  36. crate-0.35.1-py3.11-nspkg.pth +0 -1
  37. crate-0.35.1.dist-info/RECORD +0 -55
  38. crate-0.35.1.dist-info/entry_points.txt +0 -2
  39. {crate-0.35.1.dist-info → crate-1.0.0.dev0.dist-info}/LICENSE +0 -0
  40. {crate-0.35.1.dist-info → crate-1.0.0.dev0.dist-info}/NOTICE +0 -0
  41. {crate-0.35.1.dist-info → crate-1.0.0.dev0.dist-info}/namespace_packages.txt +0 -0
  42. {crate-0.35.1.dist-info → crate-1.0.0.dev0.dist-info}/top_level.txt +0 -0
crate/client/__init__.py CHANGED
@@ -29,7 +29,7 @@ __all__ = [
29
29
 
30
30
  # version string read from setup.py using a regex. Take care not to break the
31
31
  # regex!
32
- __version__ = "0.35.1"
32
+ __version__ = "1.0.0dev0"
33
33
 
34
34
  apilevel = "2.0"
35
35
  threadsafety = 2
@@ -0,0 +1,90 @@
1
+ # -*- coding: utf-8; -*-
2
+ #
3
+ # Licensed to CRATE Technology GmbH ("Crate") under one or more contributor
4
+ # license agreements. See the NOTICE file distributed with this work for
5
+ # additional information regarding copyright ownership. Crate licenses
6
+ # this file to you under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License. You may
8
+ # obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
+ # License for the specific language governing permissions and limitations
16
+ # under the License.
17
+ #
18
+ # However, if you have executed another commercial license agreement
19
+ # with Crate these terms will supersede the license and you may use the
20
+ # software solely pursuant to the terms of the relevant commercial agreement.
21
+
22
+ import os
23
+ import sys
24
+ import unittest
25
+ from datetime import datetime, date
26
+ from unittest import TestCase, mock
27
+
28
+ import time_machine
29
+
30
+
31
+ class DateTodayTest(TestCase):
32
+ """
33
+ `date.today()` returns the current local date, as advertised in the
34
+ documentation [1]. Thus, it depends on the system time zone.
35
+
36
+ The following test cases demonstrate that the test suite previously
37
+ failed around midnight, where the UTC vs. non-UTC days overlapped,
38
+ and when running on machines with non-UTC time zone.
39
+
40
+ On the other hand, `datetime.utcnow().date()` works equally well in all
41
+ situations, so we want to use that within the SQLAlchemy test cases.
42
+
43
+ Funny enough, the problem is not observable on Linux?
44
+
45
+ [1] https://docs.python.org/3/library/datetime.html#datetime.date.today
46
+ """
47
+
48
+ @mock.patch.dict(os.environ, {"TZ": "UTC"})
49
+ @time_machine.travel("2022-07-22T00:42:00+0200")
50
+ def test_date_today_depends_on_system_timezone_success_on_utc(self):
51
+ today_local = date.today()
52
+ today_utc = datetime.utcnow().date()
53
+ self.assertEqual(today_local, today_utc)
54
+ self.assertEqual(today_local, date(2022, 7, 21))
55
+ self.assertEqual(today_utc, date(2022, 7, 21))
56
+
57
+ @unittest.skipIf(sys.platform == "linux", "Problem not observable on Linux")
58
+ @mock.patch.dict(os.environ, {"TZ": "Europe/Prague"})
59
+ @time_machine.travel("2022-07-22T00:42:00+0200")
60
+ def test_date_today_depends_on_system_timezone_failure_on_non_utc(self):
61
+ today_local = date.today()
62
+ today_utc = datetime.utcnow().date()
63
+ self.assertNotEqual(today_local, today_utc)
64
+ self.assertEqual(today_local, date(2022, 7, 22))
65
+ self.assertEqual(today_utc, date(2022, 7, 21))
66
+
67
+ @mock.patch.dict(os.environ, {"TZ": "UTC"})
68
+ @time_machine.travel("2022-07-22T00:42:00+0200")
69
+ def test_date_today_utc(self):
70
+ today_local = date.today()
71
+ self.assertEqual(today_local, date(2022, 7, 21))
72
+
73
+ @unittest.skipIf(sys.platform == "linux", "Problem not observable on Linux")
74
+ @mock.patch.dict(os.environ, {"TZ": "Europe/Prague"})
75
+ @time_machine.travel("2022-07-22T00:42:00+0200")
76
+ def test_date_today_non_utc(self):
77
+ today_local = date.today()
78
+ self.assertEqual(today_local, date(2022, 7, 22))
79
+
80
+ @mock.patch.dict(os.environ, {"TZ": "UTC"})
81
+ @time_machine.travel("2022-07-22T00:42:00+0200")
82
+ def test_utcnow_date_utc(self):
83
+ today_utc = datetime.utcnow().date()
84
+ self.assertEqual(today_utc, date(2022, 7, 21))
85
+
86
+ @mock.patch.dict(os.environ, {"TZ": "Europe/Prague"})
87
+ @time_machine.travel("2022-07-22T00:42:00+0200")
88
+ def test_utcnow_date_non_utc(self):
89
+ today_utc = datetime.utcnow().date()
90
+ self.assertEqual(today_utc, date(2022, 7, 21))
@@ -0,0 +1 @@
1
+ import sys, types, os;p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('crate',));importlib = __import__('importlib.util');__import__('importlib.machinery');m = sys.modules.setdefault('crate', importlib.util.module_from_spec(importlib.machinery.PathFinder.find_spec('crate', [os.path.dirname(p)])));m = m or sys.modules.setdefault('crate', types.ModuleType('crate'));mp = (m or []) and m.__dict__.setdefault('__path__',[]);(p not in mp) and mp.append(p)
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: crate
3
- Version: 0.35.1
3
+ Version: 1.0.0.dev0
4
4
  Summary: CrateDB Python Client
5
5
  Home-page: https://github.com/crate/crate-python
6
6
  Author: Crate.io
7
7
  Author-email: office@crate.io
8
8
  License: Apache License 2.0
9
- Keywords: crate db api sqlalchemy
9
+ Keywords: cratedb db api dbapi database sql http rdbms olap
10
10
  Platform: any
11
11
  Classifier: Development Status :: 5 - Production/Stable
12
12
  Classifier: Intended Audience :: Developers
@@ -28,15 +28,11 @@ Requires-Python: >=3.6
28
28
  Description-Content-Type: text/x-rst
29
29
  License-File: LICENSE
30
30
  License-File: NOTICE
31
- Requires-Dist: urllib3 <2.2
31
+ Requires-Dist: urllib3 <2.3
32
32
  Requires-Dist: verlib2 ==0.2.0
33
33
  Provides-Extra: doc
34
34
  Requires-Dist: sphinx <8,>=3.5 ; extra == 'doc'
35
35
  Requires-Dist: crate-docs-theme >=0.26.5 ; extra == 'doc'
36
- Provides-Extra: sqlalchemy
37
- Requires-Dist: sqlalchemy <2.1,>=1.0 ; extra == 'sqlalchemy'
38
- Requires-Dist: geojson <4,>=2.5.0 ; extra == 'sqlalchemy'
39
- Requires-Dist: backports.zoneinfo <1 ; (python_version < "3.9") and extra == 'sqlalchemy'
40
36
  Provides-Extra: test
41
37
  Requires-Dist: tox <5,>=3 ; extra == 'test'
42
38
  Requires-Dist: zope.testing <6,>=4 ; extra == 'test'
@@ -44,11 +40,13 @@ Requires-Dist: zope.testrunner <7,>=5 ; extra == 'test'
44
40
  Requires-Dist: zc.customdoctests <2,>=1.0.1 ; extra == 'test'
45
41
  Requires-Dist: certifi ; extra == 'test'
46
42
  Requires-Dist: createcoverage <2,>=1 ; extra == 'test'
47
- Requires-Dist: dask ; extra == 'test'
43
+ Requires-Dist: dask[dataframe] ; extra == 'test'
48
44
  Requires-Dist: stopit <2,>=1.1.2 ; extra == 'test'
49
45
  Requires-Dist: flake8 <8,>=4 ; extra == 'test'
50
- Requires-Dist: pandas <2.1 ; extra == 'test'
46
+ Requires-Dist: pandas <2.3 ; extra == 'test'
47
+ Requires-Dist: pueblo >=0.0.7 ; extra == 'test'
51
48
  Requires-Dist: pytz ; extra == 'test'
49
+ Requires-Dist: backports.zoneinfo <1 ; (python_version < "3.9") and extra == 'test'
52
50
 
53
51
  =====================
54
52
  CrateDB Python Client
@@ -93,12 +91,11 @@ CrateDB Python Client
93
91
 
94
92
  |
95
93
 
96
- A Python client library for CrateDB_.
94
+ A Python client library for `CrateDB`_, implementing the Python `DB API 2.0`_
95
+ specification.
97
96
 
98
- This library:
99
-
100
- - Implements the Python `DB API 2.0`_ specification.
101
- - Includes support for SQLAlchemy_ in form of an `SQLAlchemy dialect`_.
97
+ The CrateDB dialect for `SQLAlchemy`_ is provided by the `sqlalchemy-cratedb`_
98
+ package.
102
99
 
103
100
 
104
101
  Installation
@@ -106,10 +103,9 @@ Installation
106
103
 
107
104
  The CrateDB Python client is available as package `crate`_ on `PyPI`_.
108
105
 
109
- To install the most recent driver version, including the SQLAlchemy dialect
110
- extension, run::
106
+ To install the most recent driver version, run::
111
107
 
112
- $ pip install "crate[sqlalchemy]" --upgrade
108
+ $ pip install --upgrade crate
113
109
 
114
110
 
115
111
  Documentation and help
@@ -139,7 +135,7 @@ GitHub`_. We appreciate contributions of any kind.
139
135
  .. _Developer documentation: DEVELOP.rst
140
136
  .. _managed on GitHub: https://github.com/crate/crate-python
141
137
  .. _PyPI: https://pypi.org/
142
- .. _SQLAlchemy: https://www.sqlalchemy.org
143
- .. _SQLAlchemy dialect: https://docs.sqlalchemy.org/dialects/
138
+ .. _SQLAlchemy: https://www.sqlalchemy.org/
139
+ .. _sqlalchemy-cratedb: https://github.com/crate-workbench/sqlalchemy-cratedb
144
140
  .. _StackOverflow: https://stackoverflow.com/tags/cratedb
145
141
  .. _support channels: https://crate.io/support/
@@ -0,0 +1,26 @@
1
+ crate-1.0.0.dev0-py3.11-nspkg.pth,sha256=gvLEjpsSy1-MTRTFCtBSJShbzWEQV_F4w4da9cFYG5Y,462
2
+ crate/client/__init__.py,sha256=6yl8zUjQTIyoaLVzENhAUj5gUekkEDYGEOwPEdI_gjA,1308
3
+ crate/client/_pep440.py,sha256=iwY5wopxbgbwsT0ImANrwN3V_ZYQHhSr7lEdVT5dQRM,42
4
+ crate/client/blob.py,sha256=plTwGEULg5s1VdKIMW6a0Zljdkng7xw0WXkXyiwNaSU,3496
5
+ crate/client/connection.py,sha256=5vmtGZF20vxoeExHTeQ-DqJX4BPNT8ebzH_HOvdcqdE,8432
6
+ crate/client/converter.py,sha256=9_-FBp8l9LwCfBsoWO0YOW0ASkwJ-le-YJFfJMLKCew,4301
7
+ crate/client/cursor.py,sha256=qnrNM9QDQgo9RFVGU7HPmCxK15EFUWiOxW3BNlZcuNw,10758
8
+ crate/client/exceptions.py,sha256=RINQtVF9jD5f_tcKpZ8A1haztKilf9HUwjESYx-W1Bk,2242
9
+ crate/client/http.py,sha256=aA6L-9i7-UovLKG3ICymRq7S0KPOIZiNejv1jzPrn4A,22559
10
+ crate/client/test_connection.py,sha256=sGsnqgpxe9sgD6TllVbQGHozf4Binrzxe_ydfAQJgWE,3670
11
+ crate/client/test_cursor.py,sha256=Q9Npq55zTY4g51kf3P7DnmTsYdv0iRwqDptKOj9ffxA,12858
12
+ crate/client/test_http.py,sha256=LvUC0QeAhH2-LJDfp2zVT6OEVTG6GKqid6qUTM9rjGY,23534
13
+ crate/client/test_util.py,sha256=k8j3Ya1fPwdfrbRkUNsqxqcyoi5Rj7O_r4HpOEdK_yA,2508
14
+ crate/testing/__init__.py,sha256=UnxmjVrk-eNORsitiM48W0pB6yfsaErOak8RYh_ELt8,10
15
+ crate/testing/layer.py,sha256=-AvRsTysqncns5IqUFWKZFppC3KwQxDJt0tnBWjxlMs,13382
16
+ crate/testing/settings.py,sha256=YTqod79NO4Lv_agPgMLGlB_fMe6baAhLXFKBZnuytBk,1652
17
+ crate/testing/test_datetime_old.py,sha256=SI0HzI8CfcbOYIj9MJz_XACrnwWyMQCZzM_Gu5PUDkI,3799
18
+ crate/testing/test_layer.py,sha256=S0QgY7TgD52EyYWrMoSLUfRVjVzw-oiUdR-g5fJ_zmQ,11512
19
+ crate/testing/util.py,sha256=qtc72rKfvfTA9VMKjE2JSukffobd7ffCcddoTiAdO6A,690
20
+ crate-1.0.0.dev0.dist-info/LICENSE,sha256=1QGh4tR_JmDKn33ztoDv2UkER0Q4Zh1kC5J3vMWwRso,12854
21
+ crate-1.0.0.dev0.dist-info/METADATA,sha256=6pYNFZUglxlJ6D8DrKMnukptx7EewcBQqgp4Aye6wqU,4801
22
+ crate-1.0.0.dev0.dist-info/NOTICE,sha256=vwbBS8sykCOndA1kjuu8dUInljH27kk3lcPBzQ2SMns,1159
23
+ crate-1.0.0.dev0.dist-info/WHEEL,sha256=DZajD4pwLWue70CAfc7YaxT1wLUciNBvN_TTcvXpltE,110
24
+ crate-1.0.0.dev0.dist-info/namespace_packages.txt,sha256=2wP2HlpxdhgTLMl9ipi168xkm6FMq9_2bf0xGGxF_OI,6
25
+ crate-1.0.0.dev0.dist-info/top_level.txt,sha256=2wP2HlpxdhgTLMl9ipi168xkm6FMq9_2bf0xGGxF_OI,6
26
+ crate-1.0.0.dev0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.42.0)
2
+ Generator: bdist_wheel (0.43.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py2-none-any
5
5
  Tag: py3-none-any
@@ -1,50 +0,0 @@
1
- # -*- coding: utf-8; -*-
2
- #
3
- # Licensed to CRATE Technology GmbH ("Crate") under one or more contributor
4
- # license agreements. See the NOTICE file distributed with this work for
5
- # additional information regarding copyright ownership. Crate licenses
6
- # this file to you under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License. You may
8
- # obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
- # License for the specific language governing permissions and limitations
16
- # under the License.
17
- #
18
- # However, if you have executed another commercial license agreement
19
- # with Crate these terms will supersede the license and you may use the
20
- # software solely pursuant to the terms of the relevant commercial agreement.
21
-
22
- from .compat.api13 import monkeypatch_add_exec_driver_sql
23
- from .dialect import CrateDialect
24
- from .sa_version import SA_1_4, SA_VERSION
25
-
26
-
27
- if SA_VERSION < SA_1_4:
28
- import textwrap
29
- import warnings
30
-
31
- # SQLAlchemy 1.3 is effectively EOL.
32
- SA13_DEPRECATION_WARNING = textwrap.dedent("""
33
- WARNING: SQLAlchemy 1.3 is effectively EOL.
34
-
35
- SQLAlchemy 1.3 is EOL since 2023-01-27.
36
- Future versions of the CrateDB SQLAlchemy dialect will drop support for SQLAlchemy 1.3.
37
- It is recommended that you transition to using SQLAlchemy 1.4 or 2.0:
38
-
39
- - https://docs.sqlalchemy.org/en/14/changelog/migration_14.html
40
- - https://docs.sqlalchemy.org/en/20/changelog/migration_20.html
41
- """.lstrip("\n"))
42
- warnings.warn(message=SA13_DEPRECATION_WARNING, category=DeprecationWarning)
43
-
44
- # SQLAlchemy 1.3 does not have the `exec_driver_sql` method, so add it.
45
- monkeypatch_add_exec_driver_sql()
46
-
47
-
48
- __all__ = [
49
- CrateDialect,
50
- ]
File without changes
@@ -1,156 +0,0 @@
1
- # -*- coding: utf-8; -*-
2
- #
3
- # Licensed to CRATE Technology GmbH ("Crate") under one or more contributor
4
- # license agreements. See the NOTICE file distributed with this work for
5
- # additional information regarding copyright ownership. Crate licenses
6
- # this file to you under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License. You may
8
- # obtain a copy of the License at
9
- #
10
- # https://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
- # License for the specific language governing permissions and limitations
16
- # under the License.
17
- #
18
- # However, if you have executed another commercial license agreement
19
- # with Crate these terms will supersede the license and you may use the
20
- # software solely pursuant to the terms of the relevant commercial agreement.
21
-
22
- """
23
- Compatibility module for running a subset of SQLAlchemy 2.0 programs on
24
- SQLAlchemy 1.3. By using monkey-patching, it can do two things:
25
-
26
- 1. Add the `exec_driver_sql` method to SA's `Connection` and `Engine`.
27
- 2. Amend the `sql.select` function to accept the calling semantics of
28
- the modern variant.
29
-
30
- Reason: `exec_driver_sql` gets used within the CrateDB dialect already,
31
- and the new calling semantics of `sql.select` already get used within
32
- many of the test cases already. Please note that the patch for
33
- `sql.select` is only applied when running the test suite.
34
- """
35
-
36
- import collections.abc as collections_abc
37
-
38
- from sqlalchemy import exc
39
- from sqlalchemy.sql import Select
40
- from sqlalchemy.sql import select as original_select
41
- from sqlalchemy.util import immutabledict
42
-
43
-
44
- # `_distill_params_20` copied from SA14's `sqlalchemy.engine.{base,util}`.
45
- _no_tuple = ()
46
- _no_kw = immutabledict()
47
-
48
-
49
- def _distill_params_20(params):
50
- if params is None:
51
- return _no_tuple, _no_kw
52
- elif isinstance(params, list):
53
- # collections_abc.MutableSequence): # avoid abc.__instancecheck__
54
- if params and not isinstance(params[0], (collections_abc.Mapping, tuple)):
55
- raise exc.ArgumentError(
56
- "List argument must consist only of tuples or dictionaries"
57
- )
58
-
59
- return (params,), _no_kw
60
- elif isinstance(
61
- params,
62
- (tuple, dict, immutabledict),
63
- # only do abc.__instancecheck__ for Mapping after we've checked
64
- # for plain dictionaries and would otherwise raise
65
- ) or isinstance(params, collections_abc.Mapping):
66
- return (params,), _no_kw
67
- else:
68
- raise exc.ArgumentError("mapping or sequence expected for parameters")
69
-
70
-
71
- def exec_driver_sql(self, statement, parameters=None, execution_options=None):
72
- """
73
- Adapter for `exec_driver_sql`, which is available since SA14, for SA13.
74
- """
75
- if execution_options is not None:
76
- raise ValueError(
77
- "SA13 backward-compatibility: "
78
- "`exec_driver_sql` does not support `execution_options`"
79
- )
80
- args_10style, kwargs_10style = _distill_params_20(parameters)
81
- return self.execute(statement, *args_10style, **kwargs_10style)
82
-
83
-
84
- def monkeypatch_add_exec_driver_sql():
85
- """
86
- Transparently add SA14's `exec_driver_sql()` method to SA13.
87
-
88
- AttributeError: 'Connection' object has no attribute 'exec_driver_sql'
89
- AttributeError: 'Engine' object has no attribute 'exec_driver_sql'
90
- """
91
- from sqlalchemy.engine.base import Connection, Engine
92
-
93
- # Add `exec_driver_sql` method to SA's `Connection` and `Engine` classes.
94
- Connection.exec_driver_sql = exec_driver_sql
95
- Engine.exec_driver_sql = exec_driver_sql
96
-
97
-
98
- def select_sa14(*columns, **kw) -> Select:
99
- """
100
- Adapt SA14/SA20's calling semantics of `sql.select()` to SA13.
101
-
102
- With SA20, `select()` no longer accepts varied constructor arguments, only
103
- the "generative" style of `select()` will be supported. The list of columns
104
- / tables to select from should be passed positionally.
105
-
106
- Derived from https://github.com/sqlalchemy/alembic/blob/b1fad6b6/alembic/util/sqla_compat.py#L557-L558
107
-
108
- sqlalchemy.exc.ArgumentError: columns argument to select() must be a Python list or other iterable
109
- """
110
- if isinstance(columns, tuple) and isinstance(columns[0], list):
111
- if "whereclause" in kw:
112
- raise ValueError(
113
- "SA13 backward-compatibility: "
114
- "`whereclause` is both in kwargs and columns tuple"
115
- )
116
- columns, whereclause = columns
117
- kw["whereclause"] = whereclause
118
- return original_select(columns, **kw)
119
-
120
-
121
- def monkeypatch_amend_select_sa14():
122
- """
123
- Make SA13's `sql.select()` transparently accept calling semantics of SA14
124
- and SA20, by swapping in the newer variant of `select_sa14()`.
125
-
126
- This supports the test suite of `crate-python`, because it already uses the
127
- modern calling semantics.
128
- """
129
- import sqlalchemy
130
-
131
- sqlalchemy.select = select_sa14
132
- sqlalchemy.sql.select = select_sa14
133
- sqlalchemy.sql.expression.select = select_sa14
134
-
135
-
136
- @property
137
- def connectionfairy_driver_connection_sa14(self):
138
- """The connection object as returned by the driver after a connect.
139
-
140
- .. versionadded:: 1.4.24
141
-
142
- .. seealso::
143
-
144
- :attr:`._ConnectionFairy.dbapi_connection`
145
-
146
- :attr:`._ConnectionRecord.driver_connection`
147
-
148
- :ref:`faq_dbapi_connection`
149
-
150
- """
151
- return self.connection
152
-
153
-
154
- def monkeypatch_add_connectionfairy_driver_connection():
155
- import sqlalchemy.pool.base
156
- sqlalchemy.pool.base._ConnectionFairy.driver_connection = connectionfairy_driver_connection_sa14