Changeset 248


Ignore:
Timestamp:
Oct 30, 2009, 2:55:39 PM (10 years ago)
Author:
marchulsman
Message:

Enhance postgres extend handling of repeated fieldnames

File:
1 edited

Legend:

Unmodified
Added
Removed
  • container/postgres.py

    r242 r248  
    410410        res = None #set to primary key if generated
    411411        if(isinstance(seq,container.Container)):
    412             seq_fieldnames = dict([(f.name,pos) for pos,f in enumerate(seq._activefields)])
    413             assert (len(seq_fieldnames)  ==  len(seq._activefields)), "Repeated names in import"
     412            seq_fieldnames = {}
     413            for pos,f in enumerate(seq._activefields):
     414                if(f.name in seq_fieldnames):
     415                    seq_fieldnames[f.name] = pos
     416                else:
     417                    seq_fieldnames[f.name] = None
    414418            ndata = numpy.empty((seq.nrow,len(self._actidx)),dtype=object)
    415419            data = seq.matrix()
     
    418422                if(field.name in seq_fieldnames):
    419423                    spos = seq_fieldnames[field.name]
     424                    assert (not spos is None), "Name " + field.name + " repeated in import"
    420425                    ndata[:,lpos] = data[:,spos]
    421426                else:
Note: See TracChangeset for help on using the changeset viewer.