Skip to content

Commit

Permalink
Merge "Change visit name for ColumnElement"
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzeek authored and Gerrit Code Review committed Dec 7, 2017
2 parents a51943a + 5e8396a commit 0493765
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
9 changes: 9 additions & 0 deletions doc/build/changelog/unreleased_12/4142.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.. change::
:tags: bug, sql
:tickets: 4142

Changed the "visit name" of :class:`.ColumnElement` from "column" to
"column_element", so that when this element is used as the basis for a
user-defined SQL element, it is not assumed to behave like a table-bound
:class:`.ColumnClause` when processed by various SQL traversal utilities,
as are commonly used by the ORM.
2 changes: 1 addition & 1 deletion lib/sqlalchemy/sql/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ class ColumnElement(operators.ColumnOperators, ClauseElement):
"""

__visit_name__ = 'column'
__visit_name__ = 'column_element'
primary_key = False
foreign_keys = []

Expand Down
16 changes: 14 additions & 2 deletions test/sql/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from sqlalchemy.testing import fixtures, is_true, is_false
from sqlalchemy.testing import fixtures, is_true, is_false, eq_
from sqlalchemy import MetaData, Table, Column, Integer, String
from sqlalchemy import and_, or_, bindparam
from sqlalchemy.sql.elements import ClauseList
from sqlalchemy.sql.elements import ClauseList, ColumnElement
from sqlalchemy.sql import operators
from sqlalchemy.sql import util as sql_util


class CompareClausesTest(fixtures.TestBase):
Expand Down Expand Up @@ -106,3 +107,14 @@ def c2(): return 6
is_false(b1.compare(b8))
is_false(b8.compare(b9))
is_true(b8.compare(b8))


class MiscTest(fixtures.TestBase):
def test_column_element_no_visit(self):
class MyElement(ColumnElement):
pass

eq_(
sql_util.find_tables(MyElement(), check_columns=True),
[]
)

0 comments on commit 0493765

Please sign in to comment.