Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #583 (closed defect: fixed)

Opened 13 years ago

Last modified 12 years ago

SQLObject Inheritables don't account for alternate id names

Reported by: kevin@… Owned by: anonymous
Priority: normal Milestone: 1.5
Component: SQLObject Version:
Severity: normal Keywords:


It looks like SQLObject's "InheritableSQLObject" fails to account for tables which have id names other than "id".

Am I missing something?

debug output:

>>> list(BizEntities.select())
 2/Select  :  SELECT biz_entities.biz_entity_id, biz_entities.child_name FROM bi
z_entities WHERE 1 = 1
 2/QueryR  :  SELECT biz_entities.biz_entity_id, biz_entities.child_name FROM bi
z_entities WHERE 1 = 1
 2/Select children of the class Person:  SELECT person.person_id, person.child_n
ame, person.first_name, person.middle_init, person.last_name, person.gender, per
son.office_phone, person.mobile_phone, person.fax_phone, person.pager_phone, per
son.email_addr, person.company_id FROM person WHERE (id IN (1, 2, 3, 4, 5, 6, 7)
 2/QueryR  :  SELECT person.person_id, person.child_name, person.first_name, per
son.middle_init, person.last_name, person.gender, person.office_phone, person.mo
bile_phone, person.fax_phone, person.pager_phone, person.email_addr, person.comp
any_id FROM person WHERE (id IN (1, 2, 3, 4, 5, 6, 7))
 2/COMMIT  :  auto
Traceback (most recent call last):
  File "<console>", line 1, in ?
  File "d:\python24\lib\site-packages\SQLObject-0.7.1dev_r1457-py2.4.egg\sqlobje
ct\sresults.py", line 149, in __iter__
    return iter(list(self.lazyIter()))
  File "d:\python24\lib\site-packages\SQLObject-0.7.1dev_r1457-py2.4.egg\sqlobje
ct\inheritance\iteration.py", line 26, in next
    if not self.lazyColumns: self.fetchChildren()
  File "d:\python24\lib\site-packages\SQLObject-0.7.1dev_r1457-py2.4.egg\sqlobje
ct\inheritance\iteration.py", line 74, in fetchChildren
    self.dbconn._executeRetry(rawconn, cursor, query)
  File "d:\python24\lib\site-packages\SQLObject-0.7.1dev_r1457-py2.4.egg\sqlobje
ct\dbconnection.py", line 295, in _executeRetry
    return cursor.execute(query)
  File "D:\Python24\lib\site-packages\sqlite\main.py", line 244, in execute
    self.rs = self.con.db.execute(SQL)
DatabaseError: no such column: id

from model.py:

class BizEntities(InheritableSQLObject):
    class sqlmeta:
        idName ='biz_entity_id'

class Person(BizEntities):
    class sqlmeta:
        idName ='person_id'
    first_name = StringCol()
    middle_init = StringCol()
    last_name = StringCol()
    gender = EnumCol(enumValues=['male','female'],default="male")
    office_phone = StringCol(default="")
    mobile_phone = StringCol(default="")
    fax_phone = StringCol(default="")
    pager_phone = StringCol(default="")
    email_addr = StringCol(default="")
    company_id = ForeignKey("Company")

class Company(BizEntities):
    class sqlmeta:
        idName ='company_id'
    company_name = StringCol()
    description = StringCol()
    web_url = StringCol()
    people = MultipleJoin("Person")
    sites = MultipleJoin("Site")

Change History

comment:1 Changed 13 years ago by jorge.vargas

  • Milestone set to 1.0

isn't this agains SQLObject rule that each table should have it's own ID?

also I see some uses of it on  http://svn.sqlobject.org/SQLObject/trunk/sqlobject/col.py

I believe SO is providing an overwrite of this which is causing your error.

could you please take this to the SO mailing list.

comment:2 Changed 12 years ago by alberto

  • Milestone changed from 1.0 to 1.1

comment:3 Changed 12 years ago by jorge.vargas

  • Status changed from new to closed
  • Resolution set to fixed

need more input

Note: See TracTickets for help on using tickets.