@@ -22,7 +22,13 @@ Unreleased
2222- Added support for enabling SSL using SQLAlchemy DB URI with parameter
2323 ``?ssl=true``.
2424
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+
2632
2733
2834Breaking changes
@@ -31,31 +37,29 @@ Breaking changes
3137Textual column expressions
3238''''''''''''''''''''''''''
3339
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. Where it was ok to use a
41+ textual column expression in *plain text* beforehand, a
42+ `SQLAlchemy literal_column`_ type should be used now. This specifically
43+ applies to `CrateDB system columns`_ like ``_score``.
3644
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::
45+ For example, when a query might have looked like this beforehand::
4146
42- sqlalchemy.exc.ArgumentError: Textual column expression '_score' should be
43- explicitly declared with text('_score'), or use column('_score') for more
44- specificity
47+ session.query(Character.name, '_score')
4548
46- The changes to be made look like this ::
49+ it should now be written like::
4750
48- old: session.query(Character.name, '_score')
49- new: session.query(Character.name, sa.literal_column('_score'))
51+ session.query(Character.name, sa.literal_column('_score'))
5052
51- ::
53+ Otherwise, SQLAlchemy will complain like ::
5254
53- old: .order_by(sa.desc(sa.text('_score')))
54- new: .order_by(sa.desc(sa.literal_column('_score')))
55+ sqlalchemy.exc.ArgumentError: Textual column expression '_score' should be
56+ explicitly declared with text('_score'), or use column('_score') for more
57+ specificity
5558
5659
57- .. _SQLAlchemy literal_column: https://docs.sqlalchemy.org/en/14/core/sqlelement.html#sqlalchemy.sql.expression.literal_column
5860.. _CrateDB system columns: https://crate.io/docs/crate/reference/en/4.8/general/ddl/system-columns.html
61+ .. _SQLAlchemy literal_column: https://docs.sqlalchemy.org/en/14/core/sqlelement.html#sqlalchemy.sql.expression.literal_column
62+ .. _What’s New in SQLAlchemy 1.4?: https://docs.sqlalchemy.org/en/14/changelog/migration_14.html
5963
6064
61652020/09/28 0.26.0
0 commit comments