Commit b918ab9
committed
SA14/Tests: Declare column expressions for
With the original code, SA14 would croak like::
sqlalchemy.exc.ArgumentError: Textual column expression '_score' should be
explicitly declared with text('_score'), or use column('_score') for more
specificity
However, when using the `sa.text` type, as suggested, older SQLAlchemy
versions will croak in this manner::
sqlalchemy.exc.InvalidRequestError: SQL expression, column, or mapped entity expected - got '<sqlalchemy.sql.elements.TextClause object at 0x10c0f7460>'
The `sa.column` type also will not work, because it would get rendered
with quotes as `"_score"`.
> `literal_column()` is similar to `column()`, except that it is more
> often used as a “standalone” column expression that renders exactly
> as stated.
>
> -- https://docs.sqlalchemy.org/en/14/core/sqlelement.html#sqlalchemy.sql.expression.literal_column
::
- SELECT characters.name AS characters_name, _score FROM characters WHERE match(characters.name, ?)
+ SELECT characters.name AS characters_name, "_score" FROM characters WHERE match(characters.name, ?)
Settling with the `sa.literal_column` type resolved any woes._score as literal_column
1 parent bd5a806 commit b918ab9
3 files changed
Lines changed: 38 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
27 | 61 | | |
28 | 62 | | |
29 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
292 | | - | |
| 292 | + | |
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
| |||
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
301 | | - | |
302 | 301 | | |
303 | 302 | | |
304 | 303 | | |
305 | | - | |
| 304 | + | |
306 | 305 | | |
307 | 306 | | |
308 | 307 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
| 112 | + | |
| 113 | + | |
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
| |||
0 commit comments