diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-03-06 16:04:46 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-03-10 16:55:03 -0400 |
commit | 693938dd6fb2f3ee3e031aed4c62355ac97f3ceb (patch) | |
tree | 94701d7df1b7274151800efd6ca996e1f4203916 /test/sql/test_operators.py | |
parent | 851fb8f5a661c66ee76308181118369c8c4df9e0 (diff) | |
download | sqlalchemy-693938dd6fb2f3ee3e031aed4c62355ac97f3ceb.tar.gz |
Rework select(), CompoundSelect() in terms of CompileState
Continuation of I408e0b8be91fddd77cf279da97f55020871f75a9
- add an options() method to the base Generative construct.
this will be where ORM options can go
- Change Null, False_, True_ to be singletons, so that
we aren't instantiating them and having to use isinstance.
The previous issue with this was that they would produce dupe
labels in SELECT statements. Apply the duplicate column
logic, newly added in 1.4, to these objects as well as to
non-apply-labels SELECT statements in general as a means of
improving this.
- create a revised system for generating ClauseList compilation
constructs that simplfies up front creation to not actually
use ClauseList; a simple tuple is rendered by the compiler
using the same constrcution rules as what are used for
ClauseList but without creating the actual object. Apply
to Select, CompoundSelect, revise Update, Delete
- Select, CompoundSelect get an initial CompileState
implementation. All methods used only within compilation
are moved here
- refine update/insert/delete compile state to not require
an outside boolean
- refine and simplify Select._copy_internals
- rework bind(), which is going away, to not use some
of the internal traversal stuff
- remove "autocommit", "for_update" parameters from Select,
references #4643
- remove "autocommit" parameter from TextClause ,
references #4643
- add deprecation warnings for statement.execute(),
engine.execute(), statement.scalar(), engine.scalar().
Fixes: #5193
Change-Id: I04ca0152b046fd42c5054ba10f37e43fc6e5a57b
Diffstat (limited to 'test/sql/test_operators.py')
-rw-r--r-- | test/sql/test_operators.py | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/test/sql/test_operators.py b/test/sql/test_operators.py index d3afc2dee..ea3a1f773 100644 --- a/test/sql/test_operators.py +++ b/test/sql/test_operators.py @@ -1106,6 +1106,7 @@ class ConjunctionTest(fixtures.TestBase, testing.AssertsCompiledSQL): def test_empty_clauses(self, op, str_op, str_continue): # these warning classes will change to ArgumentError when the # deprecated behavior is disabled + assert_raises_message( exc.SADeprecationWarning, r"Invoking %(str_op)s\(\) without arguments is deprecated, and " @@ -1199,21 +1200,35 @@ class ConjunctionTest(fixtures.TestBase, testing.AssertsCompiledSQL): select([x]).where(~null()), "SELECT x WHERE NOT NULL" ) - def test_constant_non_singleton(self): - is_not_(null(), null()) - is_not_(false(), false()) - is_not_(true(), true()) + def test_constants_are_singleton(self): + is_(null(), null()) + is_(false(), false()) + is_(true(), true()) def test_constant_render_distinct(self): self.assert_compile( - select([null(), null()]), "SELECT NULL AS anon_1, NULL AS anon_2" + select([null(), null()]), "SELECT NULL AS anon_1, NULL AS anon__1" ) self.assert_compile( - select([true(), true()]), "SELECT true AS anon_1, true AS anon_2" + select([true(), true()]), "SELECT true AS anon_1, true AS anon__1" ) self.assert_compile( select([false(), false()]), - "SELECT false AS anon_1, false AS anon_2", + "SELECT false AS anon_1, false AS anon__1", + ) + + def test_constant_render_distinct_use_labels(self): + self.assert_compile( + select([null(), null()]).apply_labels(), + "SELECT NULL AS anon_1, NULL AS anon__1", + ) + self.assert_compile( + select([true(), true()]).apply_labels(), + "SELECT true AS anon_1, true AS anon__1", + ) + self.assert_compile( + select([false(), false()]).apply_labels(), + "SELECT false AS anon_1, false AS anon__1", ) def test_is_true_literal(self): |