summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-03-24 19:24:27 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-03-24 19:24:27 +0000
commit748f9b9acfdccf614342aae71c33f4d28df0f471 (patch)
tree347302f584a4855b44a218c2ce1e32b107ad86c6 /test/sql
parente07cf69deff7e2a9152b41385c4505f1acaa958b (diff)
downloadsqlalchemy-748f9b9acfdccf614342aae71c33f4d28df0f471.tar.gz
- column labels are now generated in the compilation phase, which
means their lengths are dialect-dependent. So on oracle a label that gets truncated to 30 chars will go out to 63 characters on postgres. Also, the true labelname is always attached as the accessor on the parent Selectable so theres no need to be aware of the genrerated label names [ticket:512]. - ResultProxy column targeting is greatly simplified, and relies upon the ANSICompiler's column_labels map to translate the built-in label on a _ColumnClause (which is now considered to be a unique identifier of that column) to the label which was generated at compile time. - still need to put a baseline of ColumnClause targeting for ResultProxy objects that originated from a textual query.
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/alltests.py1
-rw-r--r--test/sql/labels.py34
2 files changed, 35 insertions, 0 deletions
diff --git a/test/sql/alltests.py b/test/sql/alltests.py
index 2517cdf8d..9f1c0d36e 100644
--- a/test/sql/alltests.py
+++ b/test/sql/alltests.py
@@ -11,6 +11,7 @@ def suite():
'sql.select',
'sql.selectable',
'sql.case_statement',
+ 'sql.labels',
# assorted round-trip tests
'sql.query',
diff --git a/test/sql/labels.py b/test/sql/labels.py
new file mode 100644
index 000000000..0b3957619
--- /dev/null
+++ b/test/sql/labels.py
@@ -0,0 +1,34 @@
+import testbase
+
+from sqlalchemy import *
+
+class LongLabelsTest(testbase.PersistTest):
+ def setUpAll(self):
+ global metadata, table1
+ metadata = MetaData(engine=testbase.db)
+ table1 = Table("some_large_named_table", metadata,
+ Column("this_is_the_primary_key_column", Integer, primary_key=True),
+ Column("this_is_the_data_column", String(30))
+ )
+ metadata.create_all()
+ table1.insert().execute(**{"this_is_the_primary_key_column":1, "this_is_the_data_column":"data1"})
+ table1.insert().execute(**{"this_is_the_primary_key_column":2, "this_is_the_data_column":"data2"})
+ table1.insert().execute(**{"this_is_the_primary_key_column":3, "this_is_the_data_column":"data3"})
+ table1.insert().execute(**{"this_is_the_primary_key_column":4, "this_is_the_data_column":"data4"})
+ def tearDownAll(self):
+ metadata.drop_all()
+
+ def test_result(self):
+ r = table1.select(use_labels=True).execute()
+ result = []
+ for row in r:
+ result.append((row[table1.c.this_is_the_primary_key_column], row[table1.c.this_is_the_data_column]))
+ assert result == [
+ (1, "data1"),
+ (2, "data2"),
+ (3, "data3"),
+ (4, "data4"),
+ ]
+
+if __name__ == '__main__':
+ testbase.main() \ No newline at end of file