diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-03-04 20:14:28 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-03-04 20:14:28 +0000 |
commit | 41e754222070ef7ee9110458937660ecd993c1b0 (patch) | |
tree | 8fe8503891d1b8b6b6765ab23de14d5c03968db0 /test/dialect/postgres.py | |
parent | 97e32c995c8791278ee995eb53af2735bbb725dd (diff) | |
download | sqlalchemy-41e754222070ef7ee9110458937660ecd993c1b0.tar.gz |
unit test for mutable PGArray, thanks to AlexB !!!
Diffstat (limited to 'test/dialect/postgres.py')
-rw-r--r-- | test/dialect/postgres.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/dialect/postgres.py b/test/dialect/postgres.py index 71fb0c763..21b11f114 100644 --- a/test/dialect/postgres.py +++ b/test/dialect/postgres.py @@ -1,6 +1,7 @@ import testenv; testenv.configure_for_tests() import datetime from sqlalchemy import * +from sqlalchemy.orm import * from sqlalchemy import exceptions from sqlalchemy.databases import postgres from sqlalchemy.engine.strategies import MockEngineStrategy @@ -705,6 +706,47 @@ class ArrayTest(TestBase, AssertsExecutionResults): self.assertEquals(results[1]['strarr'], [[u'm\xe4\xe4'], [u'm\xf6\xf6']]) arrtable.delete().execute() + def test_array_mutability(self): + class Foo(object): pass + footable = Table('foo', metadata, + Column('id', Integer, primary_key=True), + Column('intarr', postgres.PGArray(Integer), nullable=True) + ) + mapper(Foo, footable) + metadata.create_all() + sess = create_session() + + foo = Foo() + foo.id = 1 + foo.intarr = [1,2,3] + sess.save(foo) + sess.flush() + sess.clear() + foo = sess.query(Foo).get(1) + self.assertEquals(foo.intarr, [1,2,3]) + + foo.intarr.append(4) + sess.flush() + sess.clear() + foo = sess.query(Foo).get(1) + self.assertEquals(foo.intarr, [1,2,3,4]) + + foo.intarr = [] + sess.flush() + sess.clear() + self.assertEquals(foo.intarr, []) + + foo.intarr = None + sess.flush() + sess.clear() + self.assertEquals(foo.intarr, None) + + # Errors in r4217: + foo = Foo() + foo.id = 2 + sess.save(foo) + sess.flush() + class TimeStampTest(TestBase, AssertsExecutionResults): __only_on__ = 'postgres' def test_timestamp(self): |