#136 no such column with 0.7.0

closed
nobody
SQLite (24)
5
2006-01-03
2005-12-06
dvd
No

I'm tring SQLObject (v 0.7.0 easy-install)

this is my first try:
****************************************************
import sqlobject as _s

class Projects(_s.SQLObject):
project = _s.StringCol()
flags = _s.MultipleJoin('ProjectFlags')
sources = _s.MultipleJoin('ProjectSources')

@staticmethod
def newProject(pjname, **kwd):
x = Projects(project=pjname)
for name, value in kwd.items():
ProjectFlags(project=x, name=name, value=value)
return x

class ProjectFlags(_s.SQLObject):
project = _s.ForeignKey('Projects')
name = _s.StringCol()
value = _s.StringCol()

import os.path
db_filename = os.path.abspath('xxx.db')
connection = _s.connectionForURI("sqlite:/:memory:")
_s.sqlhub.processConnection = connection

Projects.createTable()
ProjectFlags.createTable()

Projects.newProject("project01", fiter="*.tiff",
max_iso=4700)

p = Projects.get(1)
print p
print p.flags
****************************************************

the last line raise:
pysqlite2.dbapi2.OperationalError: no such column:
projects_id

all works fine if I change the ProjectFlags attribute
"project" in "projects"

Is this the normal behavior?

Discussion

  • Oleg Broytman
    Oleg Broytman
    2006-01-03

    Logged In: YES
    user_id=4799

    It is normal. Either write

    projects = _s.ForeignKey('Projects')

    or

    flags = _s.MultipleJoin('ProjectFlags', joinColumn="project_id")

     
  • Oleg Broytman
    Oleg Broytman
    2006-01-03

    • status: open --> closed