diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-09-05 14:50:21 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-09-05 16:28:20 -0400 |
| commit | 356d6659b17d199c1a5ecc4241e7ee3edc6a754e (patch) | |
| tree | a6b4da92f7d0185cb876794746b6bcd16f62a8d9 /test/sql/test_labels.py | |
| parent | 2b10aa45a101acfcc6090a3801af998ef8fc1a2d (diff) | |
| download | sqlalchemy-356d6659b17d199c1a5ecc4241e7ee3edc6a754e.tar.gz | |
- tiny refactors #1-#5
Diffstat (limited to 'test/sql/test_labels.py')
| -rw-r--r-- | test/sql/test_labels.py | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/test/sql/test_labels.py b/test/sql/test_labels.py index 451757b99..4aa923080 100644 --- a/test/sql/test_labels.py +++ b/test/sql/test_labels.py @@ -1,8 +1,10 @@ -from sqlalchemy import exc as exceptions, select, MetaData, Integer, or_ +from sqlalchemy import exc as exceptions, select, MetaData, Integer, or_, \ + bindparam from sqlalchemy.engine import default from sqlalchemy.sql import table, column +from sqlalchemy.sql.elements import _truncated_label from sqlalchemy.testing import AssertsCompiledSQL, assert_raises, engines,\ - fixtures + fixtures, eq_ from sqlalchemy.testing.schema import Table, Column IDENT_LENGTH = 29 @@ -248,6 +250,47 @@ class MaxIdentTest(fixtures.TestBase, AssertsCompiledSQL): dialect=self._length_fixture(positional=True) ) + def test_bind_param_non_truncated(self): + table1 = self.table1 + stmt = table1.insert().values( + this_is_the_data_column= + bindparam("this_is_the_long_bindparam_name") + ) + compiled = stmt.compile(dialect=self._length_fixture(length=10)) + eq_( + compiled.construct_params( + params={"this_is_the_long_bindparam_name": 5}), + {'this_is_the_long_bindparam_name': 5} + ) + + def test_bind_param_truncated_named(self): + table1 = self.table1 + bp = bindparam(_truncated_label("this_is_the_long_bindparam_name")) + stmt = table1.insert().values( + this_is_the_data_column=bp + ) + compiled = stmt.compile(dialect=self._length_fixture(length=10)) + eq_( + compiled.construct_params(params={ + "this_is_the_long_bindparam_name": 5}), + {"this_1": 5} + ) + + def test_bind_param_truncated_positional(self): + table1 = self.table1 + bp = bindparam(_truncated_label("this_is_the_long_bindparam_name")) + stmt = table1.insert().values( + this_is_the_data_column=bp + ) + compiled = stmt.compile( + dialect=self._length_fixture(length=10, positional=True)) + + eq_( + compiled.construct_params(params={ + "this_is_the_long_bindparam_name": 5}), + {"this_1": 5} + ) + class LabelLengthTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = 'DefaultDialect' |
