[SQL-CVS] [ sqlobject-Bugs-1665328 ] childName column broken on leaf InheritableSQLObjects
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: SourceForge.net <no...@so...> - 2008-03-10 16:11:58
|
Bugs item #1665328, was opened at 2007-02-21 12:36 Message generated for change (Comment added) made by llucax You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1665328&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: Closed >Resolution: Invalid Priority: 5 Private: No Submitted By: Leandro Lucarella (llucax) Assigned to: Oleg Broytmann (phd) Summary: childName column broken on leaf InheritableSQLObjects Initial Comment: from sqlobject import * from sqlobject.inheritance import InheritableSQLObject __connection__ = 'sqlite:///:memory:' class Base(InheritableSQLObject): base = IntCol() Base.createTable() class Derived(Base): derived = IntCol() Derived.createTable() class Derived2(Derived): _inheritable = False derived2 = IntCol() Derived2.createTable() Base(base=1) Derived(base=2, derived=2) Derived2(base=3, derived=3, derived2=3) print Base.get(1).childName # ok (None) print Base.get(2).childName # ok (None) print Base.get(3).childName Traceback (most recent call last): File "<stdin>", line 1, in ? File "<string>", line 1, in <lambda> File "sqlobject/main.py", line 987, in _SO_loadValue result = getattr(self, attrName) AttributeError: 'Derived2' object has no attribute '_SO_val_childName' Besides the bug, what's the idea of having a 'childName' attribute if it always return None? ---------------------------------------------------------------------- >Comment By: Leandro Lucarella (llucax) Date: 2008-03-10 13:11 Message: Logged In: YES user_id=240225 Originator: YES I'm closing this bug since was somehow invalid. ---------------------------------------------------------------------- Comment By: Leandro Lucarella (llucax) Date: 2007-02-23 10:17 Message: Logged In: YES user_id=240225 Originator: YES Yes, sorry about that one, I've just realized I was using Base and not Derived2 :S Anyways, it's an odd behavior, when trying to reconstruct an InheritableSQLObject, finding the parents and obtaining it's sqlmeta.columns, one have to be careful to see if the _intheritable flag is set in the leaf to check if the childName is really present or not. I'm more, and more convinced that childName should be treated specially, like the "id" column since it's such an special case (a SQLObject artifact, and not user data). I hope you reconsider reopening 1665322. ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2007-02-23 09:38 Message: Logged In: YES user_id=4799 Originator: NO But it is not listed in Derived2.sqlmeta.columns: <class '__main__.Derived2'> {'derived2': <SOIntCol derived2>} This is exactly what "_inheritable=False" does - it removes childName from the leaf class(es). ---------------------------------------------------------------------- Comment By: Leandro Lucarella (llucax) Date: 2007-02-23 09:12 Message: Logged In: YES user_id=240225 Originator: YES But it's listed into the sqlmeta.columns: print Base.sqlmeta.columns {'base': <SOIntCol base>, 'childName': <SOStringCol childName default=None>} ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2007-02-22 16:50 Message: Logged In: YES user_id=4799 Originator: NO Oops, sorry, I reproduced the traceback. It is not a bug. You have disabled childName column by setting _inheritable = False. ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2007-02-22 16:48 Message: Logged In: YES user_id=4799 Originator: NO I cannot reproduce the bug. The program print 3 None's for me. SQLObject 0.7.3. As for the None's... I have to think about it... ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1665328&group_id=74338 |