- Declarative will raise an informative exception if
__table_args__ is passed as a tuple with no dict argument.
Improved documentation. [ticket:1468]
+
+- test
+ - Added examples into the test suite so they get exercised
+ regularly and cleaned up a couple deprecation warnings.
+
0.5.5
=======
engine = create_engine('sqlite://')
meta = MetaData(engine)
+# setup a comparator for the PickleType since it's a mutable
+# element.
+def are_elements_equal(x, y):
+ return x == y
+
# stores a top level record of an XML document.
# the "element" column will store the ElementTree document as a BLOB.
documents = Table('documents', meta,
Column('document_id', Integer, primary_key=True),
Column('filename', String(30), unique=True),
- Column('element', PickleType)
+ Column('element', PickleType(comparator=are_elements_equal))
)
meta.create_all()
class Bar(object):
def __init__(self, value):
self.data = value
-
+
+ def __eq__(self, other):
+ if not other is None:
+ return self.data == other.data
+ return NotImplemented
+
+
mapper(Foo, foo_table, extension=MyExt())
mapper(Bar, bar_table)
'employees': relation(Person, lazy=False, backref='company', cascade="all, delete-orphan")
})
-session = create_session(echo_uow=False)
+session = create_session()
c = Company(name='company1')
c.employees.append(Manager(name='pointy haired boss', status='AAB', manager_name='manager1'))
c.employees.append(Engineer(name='dilbert', status='BBA', engineer_name='engineer1', primary_language='java'))
--- /dev/null
+from sqlalchemy.test import *
+import os, re
+
+
+def find_py_files(dirs):
+ for dn in dirs:
+ dn = os.path.abspath(dn)
+ for root, dirs, files in os.walk(dn):
+ for r in '.svn', 'CVS', '.git', '.hg':
+ try:
+ dirs.remove(r)
+ except ValueError:
+ pass
+
+ pyfiles = [fn for fn in files if fn.endswith('.py')]
+ if not pyfiles:
+ continue
+
+ # Find the root of the packages.
+ packroot = root
+ while 1:
+ if not os.path.exists(os.path.join(packroot, '__init__.py')):
+ break
+ packroot = os.path.dirname(packroot)
+
+ for fn in pyfiles:
+ yield os.path.join(root[len(packroot)+1:], fn)
+
+def filename_to_module_name(fn):
+ if os.path.basename(fn) == '__init__.py':
+ fn = os.path.dirname(fn)
+ return re.sub('\.py$', '', fn.replace(os.sep, '.'))
+
+def find_modules(*args):
+ for fn in find_py_files(args or ('../examples',)):
+ yield filename_to_module_name(fn)
+
+def check_import(module):
+ __import__(module)
+
+
+class ExamplesTest(TestBase):
+ def test_examples(self):
+ for module in find_modules():
+ check_import.description = module
+ yield check_import, module