diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-10-07 09:05:34 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-10-07 09:54:39 -0400 |
| commit | 8a13957db790c77b76c11f5f43fad1492a50fcf0 (patch) | |
| tree | 893ad1e8ac70458a41916f78457ced6f59b50601 /test/sql/test_insert.py | |
| parent | ae9300cac0ec398f92d9e523273403126a709134 (diff) | |
| download | sqlalchemy-8a13957db790c77b76c11f5f43fad1492a50fcf0.tar.gz | |
Change autoincrement compileerror to a warning
Users are complaining that IntegrityError is no longer
raised.
Change-Id: I0855d5b7a98d4338f0910501b6e6d404ba33634d
Fixes: #3216
Diffstat (limited to 'test/sql/test_insert.py')
| -rw-r--r-- | test/sql/test_insert.py | 87 |
1 files changed, 53 insertions, 34 deletions
diff --git a/test/sql/test_insert.py b/test/sql/test_insert.py index f2515c4eb..3a884643b 100644 --- a/test/sql/test_insert.py +++ b/test/sql/test_insert.py @@ -5,7 +5,7 @@ from sqlalchemy import Column, Integer, MetaData, String, Table,\ from sqlalchemy.dialects import mysql, postgresql from sqlalchemy.engine import default from sqlalchemy.testing import AssertsCompiledSQL,\ - assert_raises_message, fixtures, eq_ + assert_raises_message, fixtures, eq_, expect_warnings from sqlalchemy.sql import crud class _InsertTestBase(object): @@ -484,13 +484,16 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL): 't', MetaData(), Column('x', Integer, primary_key=True), Column('y', Integer, primary_key=True) ) - assert_raises_message( - exc.CompileError, + + with expect_warnings( "Column 't.y' is marked as a member.*" "Note that as of SQLAlchemy 1.1,", - t.insert().compile, column_keys=['x'] - - ) + ): + self.assert_compile( + t.insert(), + "INSERT INTO t (x) VALUES (:x)", + params={'x': 5}, + ) def test_anticipate_no_pk_composite_pk_implicit_returning(self): t = Table( @@ -499,13 +502,17 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL): ) d = postgresql.dialect() d.implicit_returning = True - assert_raises_message( - exc.CompileError, + + with expect_warnings( "Column 't.y' is marked as a member.*" "Note that as of SQLAlchemy 1.1,", - t.insert().compile, dialect=d, column_keys=['x'] - - ) + ): + self.assert_compile( + t.insert(), + "INSERT INTO t (x) VALUES (%(x)s)", + params={"x": 5}, + dialect=d + ) def test_anticipate_no_pk_composite_pk_prefetch(self): t = Table( @@ -514,13 +521,16 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL): ) d = postgresql.dialect() d.implicit_returning = False - assert_raises_message( - exc.CompileError, + with expect_warnings( "Column 't.y' is marked as a member.*" - "Note that as of SQLAlchemy 1.1,", - t.insert().compile, dialect=d, column_keys=['x'] - - ) + "Note that as of SQLAlchemy 1.1," + ): + self.assert_compile( + t.insert(), + "INSERT INTO t (x) VALUES (%(x)s)", + params={'x': 5}, + dialect=d + ) def test_anticipate_nullable_composite_pk(self): t = Table( @@ -539,13 +549,15 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL): Column('x', Integer, primary_key=True, autoincrement=False), Column('q', Integer) ) - assert_raises_message( - exc.CompileError, + with expect_warnings( "Column 't.x' is marked as a member.*" - "may not store NULL.$", - t.insert().compile, column_keys=['q'] - - ) + "may not store NULL.$" + ): + self.assert_compile( + t.insert(), + "INSERT INTO t (q) VALUES (:q)", + params={"q": 5} + ) def test_anticipate_no_pk_non_composite_pk_implicit_returning(self): t = Table( @@ -555,13 +567,16 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL): ) d = postgresql.dialect() d.implicit_returning = True - assert_raises_message( - exc.CompileError, + with expect_warnings( "Column 't.x' is marked as a member.*" "may not store NULL.$", - t.insert().compile, dialect=d, column_keys=['q'] - - ) + ): + self.assert_compile( + t.insert(), + "INSERT INTO t (q) VALUES (%(q)s)", + params={"q": 5}, + dialect=d + ) def test_anticipate_no_pk_non_composite_pk_prefetch(self): t = Table( @@ -571,13 +586,17 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL): ) d = postgresql.dialect() d.implicit_returning = False - assert_raises_message( - exc.CompileError, - "Column 't.x' is marked as a member.*" - "may not store NULL.$", - t.insert().compile, dialect=d, column_keys=['q'] - ) + with expect_warnings( + "Column 't.x' is marked as a member.*" + "may not store NULL.$" + ): + self.assert_compile( + t.insert(), + "INSERT INTO t (q) VALUES (%(q)s)", + params={"q": 5}, + dialect=d + ) class InsertImplicitReturningTest( |
