def test_reflect(self): t1.insert().execute({u('méil'): 2, ue('\u6e2c\u8a66'): 7}) t2.insert().execute({u('a'): 2, u('b'): 2}) t3.insert().execute({ue('\u6e2c\u8a66_id'): 2, ue('unitable1_\u6e2c\u8a66'): 7, u('Unitéble2_b'): 2, ue('\u6e2c\u8a66_self'): 2}) meta = MetaData(testing.db) tt1 = Table(t1.name, meta, autoload=True) tt2 = Table(t2.name, meta, autoload=True) tt3 = Table(t3.name, meta, autoload=True) tt1.insert().execute({u('méil'): 1, ue('\u6e2c\u8a66'): 5}) tt2.insert().execute({u('méil'): 1, ue('\u6e2c\u8a66'): 1}) tt3.insert().execute({ue('\u6e2c\u8a66_id'): 1, ue('unitable1_\u6e2c\u8a66'): 5, u('Unitéble2_b'): 1, ue('\u6e2c\u8a66_self'): 1}) self.assert_(tt1.select(order_by=desc(u('méil'))).execute().fetchall() == [(2, 7), (1, 5)]) self.assert_(tt2.select(order_by=desc(u('méil'))).execute().fetchall() == [(2, 2), (1, 1)]) self.assert_(tt3.select(order_by=desc(ue('\u6e2c\u8a66_id'))). execute().fetchall() == [(2, 7, 2, 2), (1, 5, 1, 1)])
def test_repr(self): m = MetaData() t = Table( ue("\u6e2c\u8a66"), m, Column(ue("\u6e2c\u8a66_id"), Integer) ) if util.py2k: eq_( repr(t), ( "Table('\\u6e2c\\u8a66', MetaData(bind=None), " "Column('\\u6e2c\\u8a66_id', Integer(), " "table=<\u6e2c\u8a66>), " "schema=None)" ), ) else: eq_( repr(t), ( "Table('測試', MetaData(bind=None), " "Column('測試_id', Integer(), " "table=<測試>), " "schema=None)" ), )
def test_reflect(self): t1.insert().execute({u('méil'): 2, ue('\u6e2c\u8a66'): 7}) t2.insert().execute({u('a'): 2, u('b'): 2}) t3.insert().execute({ue('\u6e2c\u8a66_id'): 2, ue('unitable1_\u6e2c\u8a66'): 7, u('Unitéble2_b'): 2, ue('\u6e2c\u8a66_self'): 2}) meta = MetaData(testing.db) tt1 = Table(t1.name, meta, autoload=True) tt2 = Table(t2.name, meta, autoload=True) tt3 = Table(t3.name, meta, autoload=True) tt1.insert().execute({u('méil'): 1, ue('\u6e2c\u8a66'): 5}) tt2.insert().execute({u('méil'): 1, ue('\u6e2c\u8a66'): 1}) tt3.insert().execute({ue('\u6e2c\u8a66_id'): 1, ue('unitable1_\u6e2c\u8a66'): 5, u('Unitéble2_b'): 1, ue('\u6e2c\u8a66_self'): 1}) self.assert_( tt1.select( order_by=desc( u('méil'))).execute().fetchall() == [ (2, 7), (1, 5)]) self.assert_( tt2.select( order_by=desc( u('méil'))).execute().fetchall() == [ (2, 2), (1, 1)]) self.assert_(tt3.select(order_by=desc(ue('\u6e2c\u8a66_id'))). execute().fetchall() == [(2, 7, 2, 2), (1, 5, 1, 1)])
def test_insert(self): t1.insert().execute({u("méil"): 1, ue("\u6e2c\u8a66"): 5}) t2.insert().execute({u("a"): 1, u("b"): 1}) t3.insert().execute( {ue("\u6e2c\u8a66_id"): 1, ue("unitable1_\u6e2c\u8a66"): 5, u("Unitéble2_b"): 1, ue("\u6e2c\u8a66_self"): 1} ) assert t1.select().execute().fetchall() == [(1, 5)] assert t2.select().execute().fetchall() == [(1, 1)] assert t3.select().execute().fetchall() == [(1, 5, 1, 1)]
def test_insert(self): t1.insert().execute({u('méil'): 1, ue('\u6e2c\u8a66'): 5}) t2.insert().execute({u('a'): 1, u('b'): 1}) t3.insert().execute({ue('\u6e2c\u8a66_id'): 1, ue('unitable1_\u6e2c\u8a66'): 5, u('Unitéble2_b'): 1, ue('\u6e2c\u8a66_self'): 1}) assert t1.select().execute().fetchall() == [(1, 5)] assert t2.select().execute().fetchall() == [(1, 1)] assert t3.select().execute().fetchall() == [(1, 5, 1, 1)]
def test_repr(self): meta = MetaData() t = Table(ue("\u6e2c\u8a66"), meta, Column(ue("\u6e2c\u8a66_id"), Integer)) eq_( repr(t), ("Table('測試', MetaData(), " "Column('測試_id', Integer(), " "table=<測試>), " "schema=None)"), )
def test_insert(self): t1.insert().execute({u('méil'):1, ue('\u6e2c\u8a66'):5}) t2.insert().execute({u('a'):1, u('b'):1}) t3.insert().execute({ue('\u6e2c\u8a66_id'): 1, ue('unitable1_\u6e2c\u8a66'): 5, u('Unitéble2_b'): 1, ue('\u6e2c\u8a66_self'): 1}) assert t1.select().execute().fetchall() == [(1, 5)] assert t2.select().execute().fetchall() == [(1, 1)] assert t3.select().execute().fetchall() == [(1, 5, 1, 1)]
def test_repr(self): m = MetaData() t = Table(ue('\u6e2c\u8a66'), m, Column(ue('\u6e2c\u8a66_id'), Integer)) # I hardly understand what's going on with the backslashes in # this one on py2k vs. py3k eq_(repr(t), ("Table('\\u6e2c\\u8a66', MetaData(bind=None), " "Column('\\u6e2c\\u8a66_id', Integer(), table=<\u6e2c\u8a66>), " "schema=None)"))
def test_description_encoding(self): # amazingly, pysqlite seems to still deliver cursor.description # as encoded bytes in py2k t = Table('x', self.metadata, Column(u('méil'), Integer, primary_key=True), Column(ue('\u6e2c\u8a66'), Integer), ) self.metadata.create_all(testing.db) result = testing.db.execute(t.select()) assert u('méil') in result.keys() assert ue('\u6e2c\u8a66') in result.keys()
def test_repr(self): m = MetaData() t = Table(ue('\u6e2c\u8a66'), m, Column(ue('\u6e2c\u8a66_id'), Integer)) # I hardly understand what's going on with the backslashes in # this one on py2k vs. py3k eq_( repr(t), ( "Table('\\u6e2c\\u8a66', MetaData(bind=None), " "Column('\\u6e2c\\u8a66_id', Integer(), table=<\u6e2c\u8a66>), " "schema=None)"))
def test_insert(self): t1.insert().execute({u("méil"): 1, ue("\u6e2c\u8a66"): 5}) t2.insert().execute({u("a"): 1, u("b"): 1}) t3.insert().execute({ ue("\u6e2c\u8a66_id"): 1, ue("unitable1_\u6e2c\u8a66"): 5, u("Unitéble2_b"): 1, ue("\u6e2c\u8a66_self"): 1, }) assert t1.select().execute().fetchall() == [(1, 5)] assert t2.select().execute().fetchall() == [(1, 1)] assert t3.select().execute().fetchall() == [(1, 5, 1, 1)]
def test_unicode(self): m = MetaData() t = Table(ue('\u6e2c\u8a66'), m, Column(ue('\u6e2c\u8a66_id'), Integer)) expr = select([t]).where(t.c[ue('\u6e2c\u8a66_id')] == 5) expr2 = serializer.loads(serializer.dumps(expr, -1), m) self.assert_compile( expr2, ue('SELECT "\u6e2c\u8a66"."\u6e2c\u8a66_id" FROM "\u6e2c\u8a66" ' 'WHERE "\u6e2c\u8a66"."\u6e2c\u8a66_id" = :\u6e2c\u8a66_id_1'), dialect="default")
def test_col_targeting(self): t1.insert().execute({u("méil"): 1, ue("\u6e2c\u8a66"): 5}) t2.insert().execute({u("a"): 1, u("b"): 1}) t3.insert().execute( { ue("\u6e2c\u8a66_id"): 1, ue("unitable1_\u6e2c\u8a66"): 5, u("Unitéble2_b"): 1, ue("\u6e2c\u8a66_self"): 1, } ) row = t1.select().execute().first() eq_(row[t1.c[u("méil")]], 1) eq_(row[t1.c[ue("\u6e2c\u8a66")]], 5) row = t2.select().execute().first() eq_(row[t2.c[u("a")]], 1) eq_(row[t2.c[u("b")]], 1) row = t3.select().execute().first() eq_(row[t3.c[ue("\u6e2c\u8a66_id")]], 1) eq_(row[t3.c[ue("unitable1_\u6e2c\u8a66")]], 5) eq_(row[t3.c[u("Unitéble2_b")]], 1) eq_(row[t3.c[ue("\u6e2c\u8a66_self")]], 1)
def test_col_targeting(self, connection): connection.execute(t1.insert(), {u("méil"): 1, ue("\u6e2c\u8a66"): 5}) connection.execute(t2.insert(), {u("a"): 1, u("b"): 1}) connection.execute( t3.insert(), { ue("\u6e2c\u8a66_id"): 1, ue("unitable1_\u6e2c\u8a66"): 5, u("Unitéble2_b"): 1, ue("\u6e2c\u8a66_self"): 1, }, ) row = connection.execute(t1.select()).first() eq_(row._mapping[t1.c[u("méil")]], 1) eq_(row._mapping[t1.c[ue("\u6e2c\u8a66")]], 5) row = connection.execute(t2.select()).first() eq_(row._mapping[t2.c[u("a")]], 1) eq_(row._mapping[t2.c[u("b")]], 1) row = connection.execute(t3.select()).first() eq_(row._mapping[t3.c[ue("\u6e2c\u8a66_id")]], 1) eq_(row._mapping[t3.c[ue("unitable1_\u6e2c\u8a66")]], 5) eq_(row._mapping[t3.c[u("Unitéble2_b")]], 1) eq_(row._mapping[t3.c[ue("\u6e2c\u8a66_self")]], 1)
def test_reflect(self): t1.insert().execute({u("méil"): 2, ue("\u6e2c\u8a66"): 7}) t2.insert().execute({u("a"): 2, u("b"): 2}) t3.insert().execute( {ue("\u6e2c\u8a66_id"): 2, ue("unitable1_\u6e2c\u8a66"): 7, u("Unitéble2_b"): 2, ue("\u6e2c\u8a66_self"): 2} ) meta = MetaData(unicode_bind) tt1 = Table(t1.name, meta, autoload=True) tt2 = Table(t2.name, meta, autoload=True) tt3 = Table(t3.name, meta, autoload=True) tt1.insert().execute({u("méil"): 1, ue("\u6e2c\u8a66"): 5}) tt2.insert().execute({u("méil"): 1, ue("\u6e2c\u8a66"): 1}) tt3.insert().execute( {ue("\u6e2c\u8a66_id"): 1, ue("unitable1_\u6e2c\u8a66"): 5, u("Unitéble2_b"): 1, ue("\u6e2c\u8a66_self"): 1} ) self.assert_(tt1.select(order_by=desc(u("méil"))).execute().fetchall() == [(2, 7), (1, 5)]) self.assert_(tt2.select(order_by=desc(u("méil"))).execute().fetchall() == [(2, 2), (1, 1)]) self.assert_( tt3.select(order_by=desc(ue("\u6e2c\u8a66_id"))).execute().fetchall() == [(2, 7, 2, 2), (1, 5, 1, 1)] ) meta.drop_all() metadata.create_all()
def test_insert_unicode_keys(self, connection): table = self.tables[u("Unitéble2")] stmt = table.insert() connection.execute( stmt, [ {u("méil"): 1, ue("\u6e2c\u8a66"): 1}, {u("méil"): 2, ue("\u6e2c\u8a66"): 2}, {u("méil"): 3, ue("\u6e2c\u8a66"): 3}, ], ) eq_(connection.execute(table.select()).all(), [(1, 1), (2, 2), (3, 3)])
def test_unicode(self): m = MetaData() t = Table(ue('\u6e2c\u8a66'), m, Column(ue('\u6e2c\u8a66_id'), Integer)) expr = select([t]).where(t.c[ue('\u6e2c\u8a66_id')] == 5) expr2 = serializer.loads(serializer.dumps(expr, -1), m) self.assert_compile( expr2, ue('SELECT "\u6e2c\u8a66"."\u6e2c\u8a66_id" FROM "\u6e2c\u8a66" ' 'WHERE "\u6e2c\u8a66"."\u6e2c\u8a66_id" = :\u6e2c\u8a66_id_1'), dialect="default" )
def test_reflect(self, connection): connection.execute(t1.insert(), {u("méil"): 2, ue("\u6e2c\u8a66"): 7}) connection.execute(t2.insert(), {u("a"): 2, u("b"): 2}) connection.execute( t3.insert(), { ue("\u6e2c\u8a66_id"): 2, ue("unitable1_\u6e2c\u8a66"): 7, u("Unitéble2_b"): 2, ue("\u6e2c\u8a66_self"): 2, }, ) meta = MetaData() tt1 = Table(t1.name, meta, autoload_with=connection) tt2 = Table(t2.name, meta, autoload_with=connection) tt3 = Table(t3.name, meta, autoload_with=connection) connection.execute(tt1.insert(), {u("méil"): 1, ue("\u6e2c\u8a66"): 5}) connection.execute(tt2.insert(), {u("méil"): 1, ue("\u6e2c\u8a66"): 1}) connection.execute( tt3.insert(), { ue("\u6e2c\u8a66_id"): 1, ue("unitable1_\u6e2c\u8a66"): 5, u("Unitéble2_b"): 1, ue("\u6e2c\u8a66_self"): 1, }, ) eq_( connection.execute( tt1.select().order_by(desc(u("méil"))) ).fetchall(), [(2, 7), (1, 5)], ) eq_( connection.execute( tt2.select().order_by(desc(u("méil"))) ).fetchall(), [(2, 2), (1, 1)], ) eq_( connection.execute( tt3.select().order_by(desc(ue("\u6e2c\u8a66_id"))) ).fetchall(), [(2, 7, 2, 2), (1, 5, 1, 1)], )
def test_insert(self, connection): connection.execute(t1.insert(), {u("méil"): 1, ue("\u6e2c\u8a66"): 5}) connection.execute(t2.insert(), {u("a"): 1, u("b"): 1}) connection.execute( t3.insert(), { ue("\u6e2c\u8a66_id"): 1, ue("unitable1_\u6e2c\u8a66"): 5, u("Unitéble2_b"): 1, ue("\u6e2c\u8a66_self"): 1, }, ) eq_(connection.execute(t1.select()).fetchall(), [(1, 5)]) eq_(connection.execute(t2.select()).fetchall(), [(1, 1)]) eq_(connection.execute(t3.select()).fetchall(), [(1, 5, 1, 1)])
def test_convert_unicode(self): meta = MetaData(testing.db) t1 = Table( "unitest_table", meta, Column("id", Integer, primary_key=True), Column("descr", mssql.MSText(convert_unicode=True)), ) meta.create_all() con = testing.db.connect() # encode in UTF-8 (sting object) because this is the default # dialect encoding con.execute( ue( "insert into unitest_table values ('bien u\ umang\xc3\xa9')" ).encode("UTF-8") ) try: r = t1.select().execute().first() assert isinstance(r[1], util.text_type), ( "%s is %s instead of unicode, working on %s" % (r[1], type(r[1]), meta.bind) ) finally: meta.drop_all()
def test_convert_unicode(self, connection): meta = self.metadata t1 = Table( "unitest_table", meta, Column("id", Integer, primary_key=True), Column("descr", mssql.MSText()), ) meta.create_all(connection) connection.execute( ue("insert into unitest_table values ('abc \xc3\xa9 def')").encode( "UTF-8")) r = connection.execute(t1.select()).first() assert isinstance( r[1], util.text_type), ("%s is %s instead of unicode, working on %s" % (r[1], type(r[1]), meta.bind)) eq_(r[1], util.ue("abc \xc3\xa9 def"))
def test_convert_unicode(self): meta = self.metadata t1 = Table( "unitest_table", meta, Column("id", Integer, primary_key=True), Column("descr", mssql.MSText()), ) meta.create_all() with testing.db.connect() as con: con.execute( ue( "insert into unitest_table values ('abc \xc3\xa9 def')" ).encode("UTF-8") ) r = con.execute(t1.select()).first() assert isinstance(r[1], util.text_type), ( "%s is %s instead of unicode, working on %s" % (r[1], type(r[1]), meta.bind) ) eq_(r[1], util.ue("abc \xc3\xa9 def"))
def _assert_errorhandler(self, outconverter, has_errorhandler): data = ue("\uee2c\u9a66") # this is u"\uee2c\u9a66" utf8_w_errors = data.encode("utf-16") if has_errorhandler: eq_( outconverter(utf8_w_errors), data.encode("utf-16").decode("utf-8", "ignore"), ) else: assert_raises(UnicodeDecodeError, outconverter, utf8_w_errors)
def define_tables(cls, metadata): Table( "data", metadata, Column("id", Integer, primary_key=True), Column("x", String), Column("y", String), Column("z", Integer, server_default="5"), ) Table( u("Unitéble2"), metadata, Column(u("méil"), Integer, primary_key=True), Column(ue("\u6e2c\u8a66"), Integer), )
def _assert_errorhandler(self, outconverter, use_read, has_errorhandler): data = ue("\uee2c\u9a66") # this is u"\uee2c\u9a66" utf8_w_errors = data.encode("utf-16") if use_read: utf8_w_errors = mock.Mock(read=mock.Mock( return_value=utf8_w_errors)) if has_errorhandler: eq_( outconverter(utf8_w_errors), data.encode("utf-16").decode("utf-8", "ignore"), ) else: assert_raises(UnicodeDecodeError, outconverter, utf8_w_errors)
def test_col_targeting(self): t1.insert().execute({u('méil'): 1, ue('\u6e2c\u8a66'): 5}) t2.insert().execute({u('a'): 1, u('b'): 1}) t3.insert().execute({ue('\u6e2c\u8a66_id'): 1, ue('unitable1_\u6e2c\u8a66'): 5, u('Unitéble2_b'): 1, ue('\u6e2c\u8a66_self'): 1}) row = t1.select().execute().first() eq_(row[t1.c[u('méil')]], 1) eq_(row[t1.c[ue('\u6e2c\u8a66')]], 5) row = t2.select().execute().first() eq_(row[t2.c[u('a')]], 1) eq_(row[t2.c[u('b')]], 1) row = t3.select().execute().first() eq_(row[t3.c[ue('\u6e2c\u8a66_id')]], 1) eq_(row[t3.c[ue('unitable1_\u6e2c\u8a66')]], 5) eq_(row[t3.c[u('Unitéble2_b')]], 1) eq_(row[t3.c[ue('\u6e2c\u8a66_self')]], 1)
def test_convert_unicode(self): meta = MetaData(testing.db) t1 = Table('unitest_table', meta, Column('id', Integer, primary_key=True), Column('descr', mssql.MSText(convert_unicode=True))) meta.create_all() con = testing.db.connect() # encode in UTF-8 (sting object) because this is the default # dialect encoding con.execute(ue("insert into unitest_table values ('bien u\ umang\xc3\xa9')").encode('UTF-8')) try: r = t1.select().execute().first() assert isinstance(r[1], util.text_type), \ '%s is %s instead of unicode, working on %s' % (r[1], type(r[1]), meta.bind) finally: meta.drop_all()
def setup_class(cls): global metadata, t1, t2, t3 metadata = MetaData(testing.db) t1 = Table(u('unitable1'), metadata, Column(u('méil'), Integer, primary_key=True), Column(ue('\u6e2c\u8a66'), Integer), test_needs_fk=True, ) t2 = Table(u('Unitéble2'), metadata, Column(u('méil'), Integer, primary_key=True, key="a"), Column(ue('\u6e2c\u8a66'), Integer, ForeignKey(u('unitable1.méil')), key="b" ), test_needs_fk=True, ) # Few DBs support Unicode foreign keys if testing.against('sqlite'): t3 = Table(ue('\u6e2c\u8a66'), metadata, Column(ue('\u6e2c\u8a66_id'), Integer, primary_key=True, autoincrement=False), Column(ue('unitable1_\u6e2c\u8a66'), Integer, ForeignKey(ue('unitable1.\u6e2c\u8a66')) ), Column(u('Unitéble2_b'), Integer, ForeignKey(u('Unitéble2.b')) ), Column(ue('\u6e2c\u8a66_self'), Integer, ForeignKey(ue('\u6e2c\u8a66.\u6e2c\u8a66_id')) ), test_needs_fk=True, ) else: t3 = Table(ue('\u6e2c\u8a66'), metadata, Column(ue('\u6e2c\u8a66_id'), Integer, primary_key=True, autoincrement=False), Column(ue('unitable1_\u6e2c\u8a66'), Integer), Column(u('Unitéble2_b'), Integer), Column(ue('\u6e2c\u8a66_self'), Integer), test_needs_fk=True, ) metadata.create_all()
def define_tables(cls, metadata): global t1, t2, t3 t1 = Table( u("unitable1"), metadata, Column(u("méil"), Integer, primary_key=True), Column(ue("\u6e2c\u8a66"), Integer), test_needs_fk=True, ) t2 = Table( u("Unitéble2"), metadata, Column(u("méil"), Integer, primary_key=True, key="a"), Column( ue("\u6e2c\u8a66"), Integer, ForeignKey(u("unitable1.méil")), key="b", ), test_needs_fk=True, ) # Few DBs support Unicode foreign keys if testing.against("sqlite"): t3 = Table( ue("\u6e2c\u8a66"), metadata, Column( ue("\u6e2c\u8a66_id"), Integer, primary_key=True, autoincrement=False, ), Column( ue("unitable1_\u6e2c\u8a66"), Integer, ForeignKey(ue("unitable1.\u6e2c\u8a66")), ), Column(u("Unitéble2_b"), Integer, ForeignKey(u("Unitéble2.b"))), Column( ue("\u6e2c\u8a66_self"), Integer, ForeignKey(ue("\u6e2c\u8a66.\u6e2c\u8a66_id")), ), test_needs_fk=True, ) else: t3 = Table( ue("\u6e2c\u8a66"), metadata, Column( ue("\u6e2c\u8a66_id"), Integer, primary_key=True, autoincrement=False, ), Column(ue("unitable1_\u6e2c\u8a66"), Integer), Column(u("Unitéble2_b"), Integer), Column(ue("\u6e2c\u8a66_self"), Integer), test_needs_fk=True, )
def setup_class(cls): # trigger mysql _server_casing check... testing.db.connect().close() cls.bind = bind = engines.utf8_engine(options={"convert_unicode": True}) cls.metadata = metadata = MetaData() no_multibyte_period = set([("plain", "col_plain", "ix_plain")]) no_has_table = [ ("no_has_table_1", ue("col_Unit\u00e9ble"), ue("ix_Unit\u00e9ble")), ("no_has_table_2", ue("col_\u6e2c\u8a66"), ue("ix_\u6e2c\u8a66")), ] no_case_sensitivity = [ (ue("\u6e2c\u8a66"), ue("col_\u6e2c\u8a66"), ue("ix_\u6e2c\u8a66")), (ue("unit\u00e9ble"), ue("col_unit\u00e9ble"), ue("ix_unit\u00e9ble")), ] full = [ (ue("Unit\u00e9ble"), ue("col_Unit\u00e9ble"), ue("ix_Unit\u00e9ble")), (ue("\u6e2c\u8a66"), ue("col_\u6e2c\u8a66"), ue("ix_\u6e2c\u8a66")), ] # as you can see, our options for this kind of thing # are really limited unless you're on PG or SQLite # forget about it on these backends if not testing.requires.unicode_ddl.enabled: names = no_multibyte_period # mysql can't handle casing usually elif testing.against("mysql") and not testing.requires._has_mysql_fully_case_sensitive(): names = no_multibyte_period.union(no_case_sensitivity) # mssql + pyodbc + freetds can't compare multibyte names to # information_schema.tables.table_name elif testing.against("mssql"): names = no_multibyte_period.union(no_has_table) else: names = no_multibyte_period.union(full) for tname, cname, ixname in names: t = Table( tname, metadata, Column("id", sa.Integer, sa.Sequence(cname + "_id_seq"), primary_key=True), Column(cname, Integer), ) schema.Index(ixname, t.c[cname]) metadata.create_all(bind) cls.names = names
def setup_class(cls): global unicode_bind, metadata, t1, t2, t3 unicode_bind = utf8_engine() metadata = MetaData(unicode_bind) t1 = Table( u("unitable1"), metadata, Column(u("méil"), Integer, primary_key=True), Column(ue("\u6e2c\u8a66"), Integer), test_needs_fk=True, ) t2 = Table( u("Unitéble2"), metadata, Column(u("méil"), Integer, primary_key=True, key="a"), Column(ue("\u6e2c\u8a66"), Integer, ForeignKey(u("unitable1.méil")), key="b"), test_needs_fk=True, ) # Few DBs support Unicode foreign keys if testing.against("sqlite"): t3 = Table( ue("\u6e2c\u8a66"), metadata, Column(ue("\u6e2c\u8a66_id"), Integer, primary_key=True, autoincrement=False), Column(ue("unitable1_\u6e2c\u8a66"), Integer, ForeignKey(ue("unitable1.\u6e2c\u8a66"))), Column(u("Unitéble2_b"), Integer, ForeignKey(u("Unitéble2.b"))), Column(ue("\u6e2c\u8a66_self"), Integer, ForeignKey(ue("\u6e2c\u8a66.\u6e2c\u8a66_id"))), test_needs_fk=True, ) else: t3 = Table( ue("\u6e2c\u8a66"), metadata, Column(ue("\u6e2c\u8a66_id"), Integer, primary_key=True, autoincrement=False), Column(ue("unitable1_\u6e2c\u8a66"), Integer), Column(u("Unitéble2_b"), Integer), Column(ue("\u6e2c\u8a66_self"), Integer), test_needs_fk=True, ) metadata.create_all()
def setup_class(cls): global metadata, t1, t2, t3 metadata = MetaData(testing.db) t1 = Table( u('unitable1'), metadata, Column(u('méil'), Integer, primary_key=True), Column(ue('\u6e2c\u8a66'), Integer), test_needs_fk=True, ) t2 = Table( u('Unitéble2'), metadata, Column(u('méil'), Integer, primary_key=True, key="a"), Column(ue('\u6e2c\u8a66'), Integer, ForeignKey(u('unitable1.méil')), key="b"), test_needs_fk=True, ) # Few DBs support Unicode foreign keys if testing.against('sqlite'): t3 = Table( ue('\u6e2c\u8a66'), metadata, Column(ue('\u6e2c\u8a66_id'), Integer, primary_key=True, autoincrement=False), Column(ue('unitable1_\u6e2c\u8a66'), Integer, ForeignKey(ue('unitable1.\u6e2c\u8a66'))), Column(u('Unitéble2_b'), Integer, ForeignKey(u('Unitéble2.b'))), Column(ue('\u6e2c\u8a66_self'), Integer, ForeignKey(ue('\u6e2c\u8a66.\u6e2c\u8a66_id'))), test_needs_fk=True, ) else: t3 = Table( ue('\u6e2c\u8a66'), metadata, Column(ue('\u6e2c\u8a66_id'), Integer, primary_key=True, autoincrement=False), Column(ue('unitable1_\u6e2c\u8a66'), Integer), Column(u('Unitéble2_b'), Integer), Column(ue('\u6e2c\u8a66_self'), Integer), test_needs_fk=True, ) metadata.create_all()