I think I am following the instructions/help:
Assumption:
1) Creating The TestCase Object, with the argument owner=myOwner
establishes both sides of the 1 to Many relationship specified by the
MultipleJoin.
Is this assumption correct?
I pulled a simple standalone test from turbogears. When I run it I
get:
If this is correct, can someone do me a favor and run the sample code
on their machine and see if it works.
1) it is standalone
2) it uses a memory database
3) you can uncomment the debug line if you want to see the SQL commands
Thanks for helping a SQLObject Newbie,
Mike
----------------------- Output
------------------------------------------
<TestCase 1 name='test 1' ownerID=1>
<TestCaseOwner 1 name='owner 1'>
Traceback (most recent call last):
File "C:\devTesting\devtesting\devtesting\testing.py", line 29, in ?
print owner_1.tests
File "<string>", line 1, in <lambda>
File
"c:\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\joins.py",
line 131, in performJoin
inst.id)
File
"c:\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\dbconnection.py",
line 592, in _SO_selectJoin
return self.queryAll("SELECT %s FROM %s WHERE %s = %s" %
File
"c:\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\dbconnection.py",
line 316, in queryAll
return self._runWithConnection(self._queryAll, s)
File
"c:\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\dbconnection.py",
line 217, in _runWithConnection
val = meth(conn, *args)
File
"c:\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\dbconnection.py",
line 309, in _queryAll
self._executeRetry(conn, c, s)
File
"c:\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\dbconnection.py",
line 295, in _executeRetry
return cursor.execute(query)
pysqlite2.dbapi2.OperationalError: no such column: test_case_owner_id
------- Sample Standalone program ------------------------
from sqlobject import *
import pysqlite2.dbapi2
class TestCaseOwner(SQLObject):
name = StringCol(alternateID=True)
tests = MultipleJoin('TestCase')
class TestCase(SQLObject):
name = StringCol(alternateID=True)
owner = ForeignKey('TestCaseOwner')
connection_string = 'sqlite:/:memory'
connection = connectionForURI(connection_string)
sqlhub.threadConnection = connection
#connection.debug = True
TestCase.dropTable(ifExists=True)
TestCaseOwner.dropTable(ifExists=True)
TestCase.createTable(ifNotExists=True)
TestCaseOwner.createTable(ifNotExists=True)
new_owner = TestCaseOwner(name="owner 1")
TestCase(name="test 1", owner = new_owner)
test_case_1 = TestCase.byName("test 1")
print test_case_1
owner_1 = TestCaseOwner.byName("owner 1")
print owner_1
print owner_1.tests
Thank you very much, that was the missing link. I changed the field
name and it worked great!!!!
Mike