Contact: fumanchu@aminus.org

Log in as guest/dejavu to create tickets

I think I've seen this ORM somewhere before...

Changeset 248

Show
Ignore:
Timestamp:
07/28/06 17:58:54
Author:
dowski
Message:

Fix for #65 (JOIN bug with table prefix).

UnitClassWrapper?.association() returns tablenames. The join (and _join in storesqlite.py) methods of storage managers were treating them as class names and appending the table prefix a second time. It was also doing this if an alias was returned by association().

Also, the alias was getting the prefix appended in a WHERE clause in multiselect(), which caused errors.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/storage/db.py

    r247 r248  
    379379            ua = clsA.association(classlist2) 
    380380            if ua: 
    381                 ua, nearClass, farClass = ua 
     381                ua, nearTable, farTable = ua 
    382382                break 
    383383        if ua is None: 
     
    386386         
    387387        t = self.db 
    388         near = '%s.%s' % (t.quote(t.table_name(nearClass)), 
    389                           t.quote(t.column_name(nearClass, ua.nearKey))) 
    390         far = '%s.%s' % (t.quote(t.table_name(farClass)), 
    391                          t.quote(t.column_name(farClass, ua.farKey))) 
     388        near = '%s.%s' % (t.quote(nearTable), 
     389                          t.quote(t.column_name(nearTable, ua.nearKey))) 
     390        far = '%s.%s' % (t.quote(farTable), 
     391                         t.quote(t.column_name(farTable, ua.farKey))) 
    392392         
    393393        return "(%s %s JOIN %s ON %s = %s)" % (name1, j, name2, near, far) 
     
    439439                t = self.db[c.cls.__name__] 
    440440                if alias: 
    441                     qname = self.db.quote(self.db.table_name(c.alias)
     441                    qname = self.db.quote(c.alias
    442442                else: 
    443443                    qname = t.qname 
  • trunk/storage/storesqlite.py

    r247 r248  
    564564            ua = clsA.association(classlist2) 
    565565            if ua: 
    566                 ua, nearClass, farClass = ua 
     566                ua, nearTable, farTable = ua 
    567567                break 
    568568        if ua is None: 
     
    570570            raise errors.AssociationError(msg) 
    571571         
    572         near = '%s.%s' % (self.db.quote(self.db.table_name(nearClass)), 
    573                           self.db.quote(self.db.column_name(nearClass, ua.nearKey))) 
    574         far = '%s.%s' % (self.db.quote(self.db.table_name(farClass)), 
    575                          self.db.quote(self.db.column_name(farClass, ua.farKey))) 
     572        near = '%s.%s' % (self.db.quote(nearTable), 
     573                          self.db.quote(self.db.column_name(nearTable, ua.nearKey))) 
     574        far = '%s.%s' % (self.db.quote(farTable), 
     575                         self.db.quote(self.db.column_name(farTable, ua.farKey))) 
    576576         
    577577        on_clauses.append("%s = %s" % (near, far))