[ckan-changes] commit/vdm: kindly: fixes for sqlalchemy 0.7
Bitbucket
commits-noreply at bitbucket.org
Wed Oct 26 10:24:41 UTC 2011
1 new commit in vdm:
https://bitbucket.org/okfn/vdm/changeset/54193f2df710/
changeset: 54193f2df710
user: kindly
date: 2011-10-26 12:21:41
summary: fixes for sqlalchemy 0.7
affected #: 6 files
diff -r 2972428ed888af329095a703a926a3e3f3fe8dbb -r 54193f2df710993f48626ba93c9119755459e6b1 vdm/sqlalchemy/base.py
--- a/vdm/sqlalchemy/base.py
+++ b/vdm/sqlalchemy/base.py
@@ -5,7 +5,7 @@
import weakref
from sqlalchemy import *
-from sqlalchemy.orm.attributes import get_history
+from sqlalchemy.orm.attributes import get_history, PASSIVE_OFF
from sqlalchemy import __version__ as sqav
from sqla import SQLAlchemyMixin
@@ -550,7 +550,7 @@
for key in instance.revisioned_fields():
(added, unchanged, deleted) = get_history(state,
key,
- passive = False)
+ passive = PASSIVE_OFF)
if added or deleted:
logger.debug('check_real_change: True')
return True
diff -r 2972428ed888af329095a703a926a3e3f3fe8dbb -r 54193f2df710993f48626ba93c9119755459e6b1 vdm/sqlalchemy/demo.py
--- a/vdm/sqlalchemy/demo.py
+++ b/vdm/sqlalchemy/demo.py
@@ -16,7 +16,7 @@
TEST_ENGINE = "postgres" # or "sqlite"
if TEST_ENGINE == "postgres":
- engine = create_engine('postgres://tester:pass@localhost/vdmtest',
+ engine = create_engine('postgres://david:ytrewq@localhost/vdmtest',
pool_threadlocal=True)
else:
# setting the isolation_level is a hack required for sqlite support
diff -r 2972428ed888af329095a703a926a3e3f3fe8dbb -r 54193f2df710993f48626ba93c9119755459e6b1 vdm/sqlalchemy/stateful.py
--- a/vdm/sqlalchemy/stateful.py
+++ b/vdm/sqlalchemy/stateful.py
@@ -448,6 +448,7 @@
# collection
class OurAssociationProxy(sqlalchemy.ext.associationproxy.AssociationProxy):
+ scalar = False
def _target_is_scalar(self):
return False
diff -r 2972428ed888af329095a703a926a3e3f3fe8dbb -r 54193f2df710993f48626ba93c9119755459e6b1 vdm/sqlalchemy/test_demo_misc.py
--- a/vdm/sqlalchemy/test_demo_misc.py
+++ b/vdm/sqlalchemy/test_demo_misc.py
@@ -9,7 +9,7 @@
repo.rebuild_db()
def test_column_create(self):
- if sqav.startswith("0.6"):
+ if sqav.startswith("0.6") or sqav.startswith("0.7"):
## FIXME???
## This test does not appear to test anything that is
## VDM specific. It also fails with SQLAlchemy 0.6
@@ -76,8 +76,8 @@
assert outcol.key == incol.key
assert len(incol.foreign_keys) == 1
assert len(outcol.foreign_keys) == 1
- infk = incol.foreign_keys[0]
- outfk = outcol.foreign_keys[0]
+ infk = list(incol.foreign_keys)[0]
+ outfk = list(outcol.foreign_keys)[0]
assert infk.parent is not None
assert outfk.parent is not None
@@ -96,8 +96,8 @@
assert outcol.key == incol.key
assert len(incol.foreign_keys) == 1
assert len(outcol.foreign_keys) == 1
- infk = incol.foreign_keys[0]
- outfk = outcol.foreign_keys[0]
+ infk = list(incol.foreign_keys)[0]
+ outfk = list(outcol.foreign_keys)[0]
assert infk.parent is not None
assert outfk.parent is not None
diff -r 2972428ed888af329095a703a926a3e3f3fe8dbb -r 54193f2df710993f48626ba93c9119755459e6b1 vdm/sqlalchemy/test_stateful_collections.py
--- a/vdm/sqlalchemy/test_stateful_collections.py
+++ b/vdm/sqlalchemy/test_stateful_collections.py
@@ -3,7 +3,7 @@
from stateful import *
-engine = create_engine('sqlite:///:memory:')
+engine = create_engine('sqlite:///:memory:', echo=True)
metadata = MetaData(bind=engine)
@@ -30,7 +30,9 @@
from sqlalchemy.orm import relation, backref
SessionObject = scoped_session(create_session)
session = SessionObject()
-mapper = SessionObject.mapper
+
+from sqlalchemy.orm import mapper
+#mapper = SessionObject.mapper
from sqlalchemy.ext.associationproxy import association_proxy
from sqlalchemy.orm.collections import attribute_mapped_collection
@@ -98,7 +100,6 @@
'package_licenses', is_active=is_active, delete=delete,
undelete=undelete)
-
mapper(Package, package_table, properties={
'package_licenses':relation(PackageLicense),
})
@@ -114,6 +115,7 @@
@classmethod
def setup_class(self):
pkg1 = Package('pkg1')
+ session.add(pkg1)
lic1 = License('a')
lic2 = License('b')
lic3 = License('c')
@@ -123,19 +125,20 @@
pkg1.licenses_active.append(PackageLicense(pkg1, li))
del pkg1.licenses_active[3]
session.flush()
+
_clear()
def test_0_package_licenses(self):
- pkg1 = Package.query.get('pkg1')
+ pkg1 = session.query(Package).get('pkg1')
assert len(pkg1.package_licenses) == 4
assert pkg1.package_licenses[-1].state == 'deleted'
def test_1_licenses(self):
- p1 = Package.query.get('pkg1')
+ p1 = session.query(Package).get('pkg1')
assert len(p1.licenses) == 3
def test_2_active_deleted_and_appending(self):
- p1 = Package.query.get('pkg1')
+ p1 = session.query(Package).get('pkg1')
assert len(p1.licenses_active) == 3
assert len(p1.licenses_deleted) == 1
p1.licenses_deleted.append(PackageLicense(license=License('e')))
@@ -143,14 +146,14 @@
assert len(p1.licenses_deleted) == 2
session.flush()
_clear()
- p1 = Package.query.get('pkg1')
+ pkg1 = session.query(Package).get('pkg1')
assert len(p1.package_licenses) == 5
assert len(p1.licenses_active) == 3
assert len(p1.licenses_deleted) == 2
_clear()
def test_3_assign_etc(self):
- p1 = Package.query.get('pkg1')
+ p1 = session.query(Package).get('pkg1')
p1.licenses = []
assert len(p1.licenses) == 0
assert len(p1.licenses_active) == 0
@@ -158,7 +161,7 @@
session.flush()
_clear()
- p1 = Package.query.get('pkg1')
+ pkg1 = session.query(Package).get('pkg1')
assert len(p1.licenses) == 0
assert len(p1.package_licenses) == 5
assert len(p1.licenses_deleted) == 5
@@ -170,6 +173,7 @@
@classmethod
def setup_class(self):
pkg2 = Package('pkg2')
+ session.add(pkg2)
lic1 = License('a')
lic2 = License('b')
lic3 = License('c')
@@ -182,16 +186,16 @@
_clear()
def test_0_package_licenses(self):
- pkg2 = Package.query.get('pkg2')
+ pkg2 = session.query(Package).get('pkg2')
assert len(pkg2.package_licenses) == 4
assert pkg2.package_licenses[-1].state == 'deleted'
def test_1_licenses3(self):
- p1 = Package.query.get('pkg2')
+ p1 = session.query(Package).get('pkg2')
assert len(p1.licenses3) == 3
def test_2_active_deleted_and_appending(self):
- p1 = Package.query.get('pkg2')
+ p1 = session.query(Package).get('pkg2')
assert len(p1.licenses3_active) == 3
assert len(p1.licenses3_deleted) == 1
p1.licenses3_deleted.append(PackageLicense(license=License('e')))
@@ -199,14 +203,14 @@
assert len(p1.licenses3_deleted) == 2
session.flush()
_clear()
- p1 = Package.query.get('pkg2')
+ p1 = session.query(Package).get('pkg2')
assert len(p1.package_licenses) == 5
assert len(p1.licenses3_active) == 3
assert len(p1.licenses3_deleted) == 2
_clear()
def test_3_assign_etc(self):
- p1 = Package.query.get('pkg2')
+ p1 = session.query(Package).get('pkg2')
p1.licenses3 = []
assert len(p1.licenses3) == 0
assert len(p1.licenses3_active) == 0
@@ -214,7 +218,7 @@
session.flush()
_clear()
- p1 = Package.query.get('pkg2')
+ p1 = session.query(Package).get('pkg2')
assert len(p1.licenses3) == 0
assert len(p1.package_licenses) == 5
assert len(p1.licenses3_deleted) == 5
@@ -223,6 +227,7 @@
class TestSimple:
def test_1(self):
pkg1 = Package('pkg3')
+ session.add(pkg1)
lic1 = License('a')
lic2 = License('b')
lic3 = License('c')
@@ -237,6 +242,6 @@
_clear()
def test_2(self):
- p1 = Package.query.get('pkg3')
+ p1 = session.query(Package).get('pkg3')
assert p1.package_licenses[0].package == p1
diff -r 2972428ed888af329095a703a926a3e3f3fe8dbb -r 54193f2df710993f48626ba93c9119755459e6b1 vdm/sqlalchemy/tools.py
--- a/vdm/sqlalchemy/tools.py
+++ b/vdm/sqlalchemy/tools.py
@@ -20,7 +20,7 @@
" CASCADE")
self.execute()
postgres.dialect.schemadropper = CascadeSchemaDropper
-elif sqav.startswith("0.6"):
+elif sqav.startswith("0.6") or sqav.startswith("0.7"):
from sqlalchemy.dialects.postgresql import base
def visit_drop_table(self, drop):
return "\nDROP TABLE " + \
Repository URL: https://bitbucket.org/okfn/vdm/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the ckan-changes
mailing list