Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#188 No intermidiate table crated with one way RelatedJoin

closed-wont-fix
nobody
General (126)
5
2006-09-07
2006-07-14
Anonymous
No

I'm using SQLObject-0.7.1dev_r1675-py2.4.egg with
Turbogears 0.9a6

When running tg-admin sql (sql|create) I get notice the
following misfeature:

RelatedJoin intermediate tables are only created when
the table with the "lowest sorted" name is processed
even if only the "highest sorted" name has a RelatedJoin.

class File(SQLObject):
filename = UnicodeCol()
fileType = StringCol()
sha1HexDigest = StringCol(length=40, alternateID=True)
# NO related join here!

class Project(SQLObject, HelperClassNotSqlObject):
class sqlmeta:
# Force SQLObject to create the intermediate
# project_dumb_file table when looking at our
project
# files RelationalJoin instead of waiting to
# create it until it finds the projects
RelationalJoin
# in DumbFile (which dows not exist). Our table
must
# be lexiographically smaller than DumbFile
# a < d -> aproject < dumb_file
table = "aproject"
_defaultOrder = 'projectNumber'

projectNumber = StringCol()
files = RelatedJoin("File")
description = UnicodeCol(default="")

I do not want a relation from file to project because
many classes has files and I do not want File to have
relations to all these classes when looking at classes
related to a file is not needed but looking at files
related to a project is wery much needed.

Discussion

  • Logged In: NO

    Okay, it seems I was optimistic when renaming only the
    table. Actually the class has to be renamed, but this breaks
    with the following error:

    Traceback (most recent call last):
    File "c:\Python24\Scripts\tg-admin-script.py", line 7, in ?
    sys.exit(
    File
    "c:\python24\lib\site-packages\TurboGears-0.9a6-py2.4.egg\turbogears\command\base.py",
    line 275, in main
    command.run()
    File
    "c:\python24\lib\site-packages\TurboGears-0.9a6-py2.4.egg\turbogears\command\base.py",
    line 134, in run
    command.the_runner.run(sys.argv)
    File
    "c:\python24\lib\site-packages\SQLObject-0.7.1dev_r1675-py2.4.egg\sqlobject\manager\command.py",
    line 102, in run
    runner.run()
    File
    "c:\python24\lib\site-packages\SQLObject-0.7.1dev_r1675-py2.4.egg\sqlobject\manager\command.py",
    line 233, in run
    self.command()
    File
    "c:\python24\lib\site-packages\SQLObject-0.7.1dev_r1675-py2.4.egg\sqlobject\manager\command.py",
    line 508, in command
    print cls.createTableSQL().strip() + ';\n'
    File
    "c:\python24\lib\site-packages\SQLObject-0.7.1dev_r1675-py2.4.egg\sqlobject\main.py",
    line 1336, in createTableSQL
    sql += '\n' + cls.createJoinTablesSQL(connection=conn)
    File
    "c:\python24\lib\site-packages\SQLObject-0.7.1dev_r1675-py2.4.egg\sqlobject\main.py",
    line 1357, in createJoinTablesSQL
    for join in cls._getJoinsToCreate():
    File
    "c:\python24\lib\site-packages\SQLObject-0.7.1dev_r1675-py2.4.egg\sqlobject\main.py",
    line 1390, in _getJoinsToCreate
    if join.soClass.__name__ > join.otherClass.__name__:
    AttributeError: 'SORelatedJoin' object has no attribute
    'otherClass'

    And, I have no intention of renaming Project to aProject
    anyway ...

     
  • Oleg Broytman
    Oleg Broytman
    2006-09-07

    Logged In: YES
    user_id=4799

    Then don't do that. Create a proper RelatedJoin in the other
    direction.

     
  • Oleg Broytman
    Oleg Broytman
    2006-09-07

    • status: open --> closed-wont-fix