diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-12-08 11:23:21 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-12-08 11:23:21 -0500 |
| commit | 1ee4736beaadeb9053f8886503b64ee04fa4b557 (patch) | |
| tree | e67e2b6347a11a5eef84ff11d76c142ba53b10ff /test/sql | |
| parent | d57c1c2ddd654a1077ab04ba7277828d9030c23d (diff) | |
| parent | f8caf05593a00a61d5ef6467c334c1e594fbae86 (diff) | |
| download | sqlalchemy-1ee4736beaadeb9053f8886503b64ee04fa4b557.tar.gz | |
merge latest default
Diffstat (limited to 'test/sql')
| -rw-r--r-- | test/sql/test_operators.py | 52 | ||||
| -rw-r--r-- | test/sql/test_selectable.py | 4 | ||||
| -rw-r--r-- | test/sql/test_types.py | 17 |
3 files changed, 72 insertions, 1 deletions
diff --git a/test/sql/test_operators.py b/test/sql/test_operators.py index 9da9d94c3..45f4978ed 100644 --- a/test/sql/test_operators.py +++ b/test/sql/test_operators.py @@ -833,6 +833,58 @@ class ComparisonOperatorTest(fixtures.TestBase, testing.AssertsCompiledSQL): def test_comparison_operators_ge(self): self._test_comparison_op(operator.ge, '>=', '<=') +class NonZeroTest(fixtures.TestBase): + def _raises(self, expr): + assert_raises_message( + TypeError, + "Boolean value of this clause is not defined", + bool, expr + ) + + def _assert_true(self, expr): + is_(bool(expr), True) + + def _assert_false(self, expr): + is_(bool(expr), False) + + def test_column_identity_eq(self): + c1 = column('c1') + self._assert_true(c1 == c1) + + def test_column_identity_gt(self): + c1 = column('c1') + self._raises(c1 > c1) + + def test_column_compare_eq(self): + c1, c2 = column('c1'), column('c2') + self._assert_false(c1 == c2) + + def test_column_compare_gt(self): + c1, c2 = column('c1'), column('c2') + self._raises(c1 > c2) + + def test_binary_identity_eq(self): + c1 = column('c1') + expr = c1 > 5 + self._assert_true(expr == expr) + + def test_labeled_binary_identity_eq(self): + c1 = column('c1') + expr = (c1 > 5).label(None) + self._assert_true(expr == expr) + + def test_annotated_binary_identity_eq(self): + c1 = column('c1') + expr1 = (c1 > 5) + expr2 = expr1._annotate({"foo": "bar"}) + self._assert_true(expr1 == expr2) + + def test_labeled_binary_compare_gt(self): + c1 = column('c1') + expr1 = (c1 > 5).label(None) + expr2 = (c1 > 5).label(None) + self._assert_false(expr1 == expr2) + class NegationTest(fixtures.TestBase, testing.AssertsCompiledSQL): __dialect__ = 'default' diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py index 65dc65470..a60916b44 100644 --- a/test/sql/test_selectable.py +++ b/test/sql/test_selectable.py @@ -1287,7 +1287,9 @@ class AnnotationsTest(fixtures.TestBase): t.c.x, a, s, - s2 + s2, + t.c.x > 1, + (t.c.x > 1).label(None) ]: annot = obj._annotate({}) eq_(set([obj]), set([annot])) diff --git a/test/sql/test_types.py b/test/sql/test_types.py index f9ab785ed..8987743d4 100644 --- a/test/sql/test_types.py +++ b/test/sql/test_types.py @@ -1306,6 +1306,23 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): dialects.mysql.INTEGER(display_width=5), "INTEGER(5)", allow_dialect_select=True) + def test_numeric_plain(self): + self.assert_compile(types.NUMERIC(), 'NUMERIC') + + def test_numeric_precision(self): + self.assert_compile(types.NUMERIC(2), 'NUMERIC(2)') + + def test_numeric_scale(self): + self.assert_compile(types.NUMERIC(2, 4), 'NUMERIC(2, 4)') + + def test_decimal_plain(self): + self.assert_compile(types.DECIMAL(), 'DECIMAL') + + def test_decimal_precision(self): + self.assert_compile(types.DECIMAL(2), 'DECIMAL(2)') + + def test_decimal_scale(self): + self.assert_compile(types.DECIMAL(2, 4), 'DECIMAL(2, 4)') |
