mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-05-20 15:42:11 -04:00
748f9b9acf
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.
34 lines
1.3 KiB
Python
34 lines
1.3 KiB
Python
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() |