@@ -22,7 +22,13 @@ Unreleased
22
22
- Added support for enabling SSL using SQLAlchemy DB URI with parameter
23
23
``?ssl=true``.
24
24
25
- - Add support for SQLAlchemy 1.4
25
+ - Added support for SQLAlchemy 1.4
26
+
27
+ .. note::
28
+
29
+ For learning about the transition to SQLAlchemy 1.4, we recommend the
30
+ corresponding documentation `What’s New in SQLAlchemy 1.4?`_.
31
+
26
32
27
33
28
34
Breaking changes
@@ -31,31 +37,26 @@ Breaking changes
31
37
Textual column expressions
32
38
''''''''''''''''''''''''''
33
39
34
- On the update to SQLAlchemy 1.4, some test cases had to be adjusted in order
35
- to compensate for apparent additional strictness of SQLAlchemy on some details.
40
+ SQLAlchemy 1.4 became stricter on some details. It requires to wrap `CrateDB
41
+ system columns`_ like ``_score`` in a `SQLAlchemy literal_column`_ type.
42
+ Before, it was possible to use a query like this::
36
43
37
- Where it was ok to use a textual column expression in plain text beforehand,
38
- a `SQLAlchemy literal_column`_ type should be used now. Otherwise, for example
39
- when accessing `CrateDB system columns`_ like ``_score``, the engine might
40
- complain like::
41
-
42
- sqlalchemy.exc.ArgumentError: Textual column expression '_score' should be
43
- explicitly declared with text('_score'), or use column('_score') for more
44
- specificity
44
+ session.query(Character.name, '_score')
45
45
46
- The changes to be made look like this ::
46
+ It must now be written like::
47
47
48
- old: session.query(Character.name, '_score')
49
- new: session.query(Character.name, sa.literal_column('_score'))
48
+ session.query(Character.name, sa.literal_column('_score'))
50
49
51
- ::
50
+ Otherwise, SQLAlchemy will complain like ::
52
51
53
- old: .order_by(sa.desc(sa.text('_score')))
54
- new: .order_by(sa.desc(sa.literal_column('_score')))
52
+ sqlalchemy.exc.ArgumentError: Textual column expression '_score' should be
53
+ explicitly declared with text('_score'), or use column('_score') for more
54
+ specificity
55
55
56
56
57
- .. _SQLAlchemy literal_column: https://docs.sqlalchemy.org/en/14/core/sqlelement.html#sqlalchemy.sql.expression.literal_column
58
57
.. _CrateDB system columns: https://crate.io/docs/crate/reference/en/4.8/general/ddl/system-columns.html
58
+ .. _SQLAlchemy literal_column: https://docs.sqlalchemy.org/en/14/core/sqlelement.html#sqlalchemy.sql.expression.literal_column
59
+ .. _What’s New in SQLAlchemy 1.4?: https://docs.sqlalchemy.org/en/14/changelog/migration_14.html
59
60
60
61
61
62
2020/09/28 0.26.0
0 commit comments