Patches item #1576143, was opened at 2006-10-12 21:18
Message generated for change (Comment added) made by trlandet
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1576143&group_id=74338
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: Bug in handling of non default foreign key values
Initial Comment:
se:
http://trac.turbogears.org/turbogears/ticket/1139
for bug description and patch.
Thanks,
Tormod Ravnanger Landet
----------------------------------------------------------------------
Comment By: Tormod R Landet (trlandet)
Date: 2006-10-27 00:34
Message:
Logged In: YES
user_id=1631055
Fix:
change the file sqlobject.inheritance.init line 218
from:
if col._default == sqlbuilder.NoDefault and col.name not in kw:
to:
if col._default == sqlbuilder.NoDefault and col.name not in
kw and (col.foreignName is None or col.foreignName not in kw):
----------------------------------------------------------------------
Comment By: Tormod R Landet (trlandet)
Date: 2006-10-27 00:31
Message:
Logged In: YES
user_id=1631055
Seems there is a problem adding files
Testcase to show the bug:
from sqlobject import *
from sqlobject.inheritance import InheritableSQLObject
class Base(InheritableSQLObject):
pass
class File(SQLObject):
pass
class MyClass(Base):
aFile = ForeignKey("Base")
otherFile = ForeignKey("Base", default=None)
sqlhub.processConnection = connectionForURI('sqlite:/:memory:')
Base.createTable()
File.createTable()
MyClass.createTable()
file1 = File()
file2 = File()
print MyClass.sqlmeta.columnList
# [<SOStringCol childName default=None>, <SOForeignKey
aFileID connected to Base>, <SOForeignKey otherFileID
default=None connected to Base>]
object = MyClass(aFile=file1, otherFile=file2)
# Traceback (most recent call last):
# File "/home/landet/work/eclipseworkspace/Diverse
Pythonscript/src/SQLObject_bugfixing/case.py", line 23, in ?
# object = MyClass(aFile=file1, otherFile=file2)
# File
"/home/landet/lib/python-2.4/SQLObject-0.7.1-py2.4.egg/sqlobject/declarative.py",
line 93, in _wrapper
# return fn(self, *args, **kwargs)
# File
"/home/landet/lib/python-2.4/SQLObject-0.7.1-py2.4.egg/sqlobject/main.py",
line 1198, in __init__
# self._create(id, **kw)
# File
"/home/landet/lib/python-2.4/SQLObject-0.7.1-py2.4.egg/sqlobject/inheritance/__init__.py",
line 219, in _create
# raise TypeError, "%s() did not get expected keyword
argument %s" % (self.__class__.__name__, col.name)
# TypeError: MyClass() did not get expected keyword argument
aFileID
----------------------------------------------------------------------
Comment By: Tormod R Landet (trlandet)
Date: 2006-10-27 00:27
Message:
Logged In: YES
user_id=1631055
Adding testcase
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1576143&group_id=74338
|