From 693938dd6fb2f3ee3e031aed4c62355ac97f3ceb Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 6 Mar 2020 16:04:46 -0500 Subject: 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 --- test/sql/test_utils.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/sql/test_utils.py') diff --git a/test/sql/test_utils.py b/test/sql/test_utils.py index 48d6de6db..1ccd1e123 100644 --- a/test/sql/test_utils.py +++ b/test/sql/test_utils.py @@ -1,3 +1,9 @@ +from sqlalchemy import Column +from sqlalchemy import Integer +from sqlalchemy import MetaData +from sqlalchemy import select +from sqlalchemy import String +from sqlalchemy import Table from sqlalchemy.sql import util as sql_util from sqlalchemy.sql.elements import ColumnElement from sqlalchemy.testing import eq_ @@ -10,3 +16,17 @@ class MiscTest(fixtures.TestBase): _traverse_internals = [] eq_(sql_util.find_tables(MyElement(), check_columns=True), []) + + def test_find_tables_selectable(self): + metadata = MetaData() + common = Table( + "common", + metadata, + Column("id", Integer, primary_key=True), + Column("data", Integer), + Column("extra", String(45)), + ) + + subset_select = select([common.c.id, common.c.data]).alias() + + eq_(sql_util.find_tables(subset_select), [common]) -- cgit v1.2.1