diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-08-31 20:38:14 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-08-31 20:38:14 +0000 |
commit | 3d38969fd4f88d996d438df63f7cbb1833b63429 (patch) | |
tree | 33f33709c5abcfad827bcc0460f9a51558e36542 /test/dialect/test_postgresql.py | |
parent | f3480a7ff4d0994bf201f830f31f416a7b1e9f0f (diff) | |
download | sqlalchemy-3d38969fd4f88d996d438df63f7cbb1833b63429.tar.gz |
- Inserting NULL into a primary key + foreign key column
will allow the "not null constraint" error to raise,
not an attempt to execute a nonexistent "col_id_seq"
sequence. [ticket:1516]
- autoincrement SELECT statements, i.e. those which
select from a procedure that modifies rows, now work
with server-side cursor mode (the named cursor isn't
used for such statements.)
Diffstat (limited to 'test/dialect/test_postgresql.py')
-rw-r--r-- | test/dialect/test_postgresql.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/dialect/test_postgresql.py b/test/dialect/test_postgresql.py index e1c351a93..c27e24e43 100644 --- a/test/dialect/test_postgresql.py +++ b/test/dialect/test_postgresql.py @@ -131,6 +131,28 @@ class InsertTest(TestBase, AssertsExecutionResults): ins.execute({'x':"five"}, {'x':"seven"}) assert table.select().execute().fetchall() == [(1, 'five'), (2, 'seven')] + def test_foreignkey_missing_insert(self): + t1 = Table('t1', metadata, + Column('id', Integer, primary_key=True) + ) + t2 = Table('t2', metadata, + Column('id', Integer, ForeignKey('t1.id'), primary_key=True) + ) + metadata.create_all() + + # want to ensure that + # "null value in column "id" violates not-null constraint" is raised (IntegrityError on psycoopg2, + # but ProgrammingError on pg8000), + # and not "ProgrammingError: (ProgrammingError) relation "t2_id_seq" does not exist". + # the latter corresponds to autoincrement behavior, which is not the case + # here due to the foreign key. + for eng in [ + engines.testing_engine(options={'implicit_returning':False}), + engines.testing_engine(options={'implicit_returning':True}), + ]: + assert_raises_message(exc.DBAPIError, "violates not-null constraint", eng.execute, t2.insert()) + + def test_sequence_insert(self): table = Table('testtable', metadata, Column('id', Integer, Sequence('my_seq'), primary_key=True), |