"""
__visit_name__ = 'bindparam'
-
+ quote = None
+
def __init__(self, key, value, type_=None, unique=False, isoutparam=False, shortname=None):
"""Construct a _BindParamClause.
self.name = name or "{ANON %d %s}" % (id(self), getattr(element, 'name', 'anon'))
self.element = element.self_group(against=operators.as_)
self.type = sqltypes.to_instance(type_ or getattr(element, 'type', None))
+ self.quote = element.quote
def key(self):
return self.name
mapper(Sub1, sub1)
mapper(Sub2, sub2)
sess = create_session()
- b1 = Base(data='b1', sub1=[Sub1(data='s11')], sub2=[])
- b2 = Base(data='b1', sub1=[Sub1(data='s12')], sub2=[Sub2(data='s2')])
+
+ s11 = Sub1(data='s11')
+ s12 = Sub1(data='s12')
+ s2 = Sub2(data='s2')
+ b1 = Base(data='b1', sub1=[s11], sub2=[])
+ b2 = Base(data='b1', sub1=[s12], sub2=[])
sess.add(b1)
sess.add(b2)
sess.flush()
+ # theres an overlapping ForeignKey here, so not much option except
+ # to artifically control the flush order
+ b2.sub2 = [s2]
+ sess.flush()
+
q = sess.query(Base).outerjoin('sub2', aliased=True)
assert sub1.c.id not in q._filter_aliases.equivalents
Column('col1', Integer, quote=True), quote=True, schema="foo", quote_schema=True)
self.assert_compile(t1.select(), '''SELECT "foo"."t1"."col1" FROM "foo"."t1"''')
+ self.assert_compile(t1.select().apply_labels(), '''SELECT "foo"."t1"."col1" AS "foo_t1_col1" FROM "foo"."t1"''')
+ a = t1.select().alias('anon')
+ b = select([1], a.c.col1==2, from_obj=a)
+ self.assert_compile(b,
+ '''SELECT 1 FROM (SELECT "foo"."t1"."col1" AS "col1" FROM '''\
+ '''"foo"."t1") AS anon WHERE anon."col1" = :col1_1'''
+ )
+
metadata = MetaData()
t1 = Table('TableOne', metadata,
Column('ColumnOne', Integer, quote=False), quote=False, schema="FooBar", quote_schema=False)
- self.assert_compile(t1.select(), '''SELECT FooBar.TableOne.ColumnOne FROM FooBar.TableOne''')
+ self.assert_compile(t1.select(), "SELECT FooBar.TableOne.ColumnOne FROM FooBar.TableOne")
+
+ self.assert_compile(t1.select().apply_labels(),
+ "SELECT FooBar.TableOne.ColumnOne AS "\
+ "FooBar_TableOne_ColumnOne FROM FooBar.TableOne" # TODO: is this what we really want here ? what if table/schema
+ # *are* quoted?
+ )
+
+ a = t1.select().alias('anon')
+ b = select([1], a.c.ColumnOne==2, from_obj=a)
+ self.assert_compile(b,
+ "SELECT 1 FROM (SELECT FooBar.TableOne.ColumnOne AS "\
+ "ColumnOne FROM FooBar.TableOne) AS anon WHERE anon.ColumnOne = :ColumnOne_1"
+ )
+
+
def test_table_quote_flag(self):
metadata = MetaData()