diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-03-27 16:04:34 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-03-27 16:04:34 +0000 |
| commit | 32440f2b3b61deda5bd8ee0abf707b76f44c926d (patch) | |
| tree | 027bb110eed295ad768564049d548c07272a035e /test | |
| parent | 363405aa9982fe46096f8b4991a59baf5e09294d (diff) | |
| download | sqlalchemy-32440f2b3b61deda5bd8ee0abf707b76f44c926d.tar.gz | |
- preliminary support for unicode table and column names added.
Diffstat (limited to 'test')
| -rw-r--r-- | test/sql/alltests.py | 1 | ||||
| -rw-r--r-- | test/sql/select.py | 1 | ||||
| -rw-r--r-- | test/sql/unicode.py | 66 | ||||
| -rw-r--r-- | test/testbase.py | 2 |
4 files changed, 69 insertions, 1 deletions
diff --git a/test/sql/alltests.py b/test/sql/alltests.py index 9f1c0d36e..7be1a3ffb 100644 --- a/test/sql/alltests.py +++ b/test/sql/alltests.py @@ -12,6 +12,7 @@ def suite(): 'sql.selectable', 'sql.case_statement', 'sql.labels', + 'sql.unicode', # assorted round-trip tests 'sql.query', diff --git a/test/sql/select.py b/test/sql/select.py index 1ca8224a8..5fcf88fd1 100644 --- a/test/sql/select.py +++ b/test/sql/select.py @@ -4,6 +4,7 @@ from sqlalchemy import * from sqlalchemy.databases import sqlite, postgres, mysql, oracle, firebird import unittest, re + # the select test now tests almost completely with TableClause/ColumnClause objects, # which are free-roaming table/column objects not attached to any database. # so SQLAlchemy's SQL construction engine can be used with no database dependencies at all. diff --git a/test/sql/unicode.py b/test/sql/unicode.py new file mode 100644 index 000000000..1e1b414ea --- /dev/null +++ b/test/sql/unicode.py @@ -0,0 +1,66 @@ +# coding: utf-8 +import testbase + +from sqlalchemy import * + +"""verrrrry basic unicode column name testing""" + +class UnicodeSchemaTest(testbase.PersistTest): + @testbase.unsupported('postgres') + def setUpAll(self): + global metadata, t1, t2 + metadata = MetaData(engine=testbase.db) + t1 = Table('unitable1', metadata, + Column(u'méil', Integer, primary_key=True), + Column(u'éXXm', Integer), + + ) + t2 = Table(u'unitéble2', metadata, + Column(u'méil', Integer, primary_key=True, key="a"), + Column(u'éXXm', Integer, ForeignKey(u'unitable1.méil'), key="b"), + + ) + + metadata.create_all() + @testbase.unsupported('postgres') + def tearDownAll(self): + metadata.drop_all() + + @testbase.unsupported('postgres') + def test_insert(self): + t1.insert().execute({u'méil':1, u'éXXm':5}) + t2.insert().execute({'a':1, 'b':5}) + + assert t1.select().execute().fetchall() == [(1, 5)] + assert t2.select().execute().fetchall() == [(1, 5)] + + @testbase.unsupported('postgres') + def test_mapping(self): + # TODO: this test should be moved to the ORM tests, tests should be + # added to this module testing SQL syntax and joins, etc. + class A(object):pass + class B(object):pass + + mapper(A, t1, properties={ + 't2s':relation(B), + 'a':t1.c[u'méil'], + 'b':t1.c[u'éXXm'] + }) + mapper(B, t2) + sess = create_session() + a1 = A() + b1 = B() + a1.t2s.append(b1) + sess.save(a1) + sess.flush() + sess.clear() + new_a1 = sess.query(A).selectone(t1.c[u'méil'] == a1.a) + assert new_a1.a == a1.a + assert new_a1.t2s[0].a == b1.a + sess.clear() + new_a1 = sess.query(A).options(eagerload('t2s')).selectone(t1.c[u'méil'] == a1.a) + assert new_a1.a == a1.a + assert new_a1.t2s[0].a == b1.a + +if __name__ == '__main__': + testbase.main()
\ No newline at end of file diff --git a/test/testbase.py b/test/testbase.py index 34c05b8e5..88519ef41 100644 --- a/test/testbase.py +++ b/test/testbase.py @@ -263,7 +263,7 @@ class EngineAssert(proxy.BaseProxyEngine): def post_exec(engine, proxy, compiled, parameters, **kwargs): ctx = e self.engine.logger = self.logger - statement = str(compiled) + statement = unicode(compiled) statement = re.sub(r'\n', '', statement) if self.assert_list is not None: |
