lost reference to self in case of self-referring cycle reference over the inheritance and relation

Issue #1449 resolved
Former user created an issue

The reference to the same object is lost after the commit, while to other object is still working, but strangelly a bit. The (cycle-referenced) structure of data is: [BR] DataObject inherited by DataObjectType referenced by DataObject. See applied test script for details. [BR] Expected result:

Before commit
1>>>>>>>>>>base_meta.name DataObjectType
2>>>>>>>>>>base_meta.object_type_guid 2
3>>>>>>>>>>base_meta.object_type <__main__.DataObjectType object at 0x8b4d86c>
4>>>>>>>>>>base_meta.object_type.name DataObjectType
1>>>>>>>>>>other_meta.name DataObject
2>>>>>>>>>>other_meta.object_type_guid 2
3>>>>>>>>>>other_meta.object_type <__main__.DataObjectType object at 0x8b4d86c>
4>>>>>>>>>>other_meta.object_type.name DataObjectType
After commit
1>>>>>>>>>>base_meta.name DataObjectType
2>>>>>>>>>>base_meta.object_type_guid 2
3>>>>>>>>>>base_meta.object_type <__main__.DataObjectType object at 0x8b4d86c>
4>>>>>>>>>>base_meta.object_type.name DataObjectType
1>>>>>>>>>>other_meta.name DataObject
2>>>>>>>>>>other_meta.object_type_guid 2
3>>>>>>>>>>other_meta.object_type <__main__.DataObjectType object at 0x8b4d86c>
4>>>>>>>>>>other_meta.object_type.name DataObjectType

Actual result:

Before commit
1>>>>>>>>>>base_meta.name DataObjectType
2>>>>>>>>>>base_meta.object_type_guid 2
3>>>>>>>>>>base_meta.object_type <__main__.DataObjectType object at 0x98e886c>
4>>>>>>>>>>base_meta.object_type.name DataObjectType
1>>>>>>>>>>other_meta.name DataObject
2>>>>>>>>>>other_meta.object_type_guid None
3>>>>>>>>>>other_meta.object_type <__main__.DataObjectType object at 0x98e886c>
4>>>>>>>>>>other_meta.object_type.name DataObjectType
After commit
1>>>>>>>>>>base_meta.name DataObjectType
2>>>>>>>>>>base_meta.object_type_guid None
3>>>>>>>>>>base_meta.object_type None
4>>>>>>>>>>base_meta.object_type.name !!!!!!! 'NoneType' object has no attribute 'name'
1>>>>>>>>>>other_meta.name DataObject
2>>>>>>>>>>other_meta.object_type_guid 2
3>>>>>>>>>>other_meta.object_type <__main__.DataObjectType object at 0x98e886c>
4>>>>>>>>>>other_meta.object_type.name DataObjectType

Note 1:[BR] ''Setting-up a relation using foreign key field instead of a relation itself works fine (comment out the line marked (1) and uncomment line marked (2) and you can see expected result).''[BR] Note2:[BR] ''See to result lines marked 2>>.. Before commit it contains good value for the base_meta object, bud wrong value for the other_meta object. After commit it looks contrary.''[BR] Note 3:[BR] ''Seeing a log switched on, I've noticed, that the update command has not been issued at all for the base_meta object''[BR] Note 4:[BR] ''While the version of my sqlalchemy installation is not last (see below), I think the bug might remain actual, because I didn't find any bug report related to this case''[BR] Some system details:[BR]

seva@seva:~/mixture$ python
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[4.3.3](GCC) on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlalchemy
>>> sqlalchemy.__version__
'0.5.3'
>>>
seva@seva:~/mixture$ uname -a
Linux seva 2.6.28-11-generic #42-Ubuntu SMP Fri Apr 17 01:57:59 UTC 2009 i686 GNU/Linux

Comments (4)

  1. Former user Account Deleted

    The just downloaded sqlalchemy 0.5.4p2 demonstrates the same problem.[BR] Vsevolod Novikov[BR] Nizhny Novgorod[BR] nnseva(at)mail.ru

  2. Mike Bayer repo owner

    solution:

    DataObject.object_type  = relation(DataObjectType,primaryjoin=DataObject.object_type_guid==DataObjectType.type_guid, post_update=True)
    
  3. Log in to comment