[z3-checkins] r36884 - z3/sqlos/trunk/src/sqlos
kobold at codespeak.net
kobold at codespeak.net
Wed Jan 17 18:14:20 CET 2007
Author: kobold
Date: Wed Jan 17 18:14:19 2007
New Revision: 36884
Modified:
z3/sqlos/trunk/src/sqlos/zsqlobject.py
Log:
Added a new test.
Modified: z3/sqlos/trunk/src/sqlos/zsqlobject.py
==============================================================================
--- z3/sqlos/trunk/src/sqlos/zsqlobject.py (original)
+++ z3/sqlos/trunk/src/sqlos/zsqlobject.py Wed Jan 17 18:14:19 2007
@@ -121,6 +121,46 @@
>>> testdb.tearDown()
+ Test a join with None values:
+
+ >>> from sqlobject import *
+ >>> from zope.interface import Attribute
+ >>> from sqlos.interfaces import ISQLSchema
+
+ >>> class IPerson(ISQLSchema):
+ ... fullname = Attribute(u'Fullname')
+ ... company = Attribute(u'Company')
+
+ >>> class Person(SQLOSContainer):
+ ... fullname = UnicodeCol(length=100)
+ ... company = SingleJoin('Company')
+
+ >>> class ICompany(ISQLSchema):
+ ... name = Attribute(u'Name')
+ ... person = Attribute(u'Person')
+
+ >>> class Company(SQLOSContainer):
+ ... name = UnicodeCol(length=100)
+ ... person = ForeignKey('Person')
+
+ >>> testdb = testing.TestDB([Person, Company])
+ >>> person = Person(fullname='John Doe')
+ >>> person.company is None
+ True
+ >>> list(person.keys())
+ []
+
+ >>> company = Company(name='Company Ltd.', person=person)
+ >>> list(person.keys())
+ ['company']
+
+ >>> person['company'].name
+ u'Company Ltd.'
+
+ And finally call tearDown and cleanup:
+
+ >>> testdb.tearDown()
+
"""
implements(IReadContainer)
More information about the z3-checkins
mailing list