Thanks Mike. That fixed it!. On Monday, May 23, 2016 at 10:18:15 AM UTC-4, Mike Bayer wrote: > > > > On 05/23/2016 10:12 AM, Brian Cherinka wrote: > > > > Hi, > > > > It seems like the ARRAY option zero_indexes=True is broken for > > 2-dimensional arrays. Is this a bug that is fixed in 1.1? I'm > > actually using the subclass ARRAY_D as a fix for the __getitem__ > > indexing. It works for 1-D arrays. > > > > > if you're passing zero_indexes=True then that needs to be propagated to > the new ARRAY type being created inside of __getitem__. The recipe > appears to miss this. > > class ARRAY_D(ARRAY): > class Comparator(ARRAY.Comparator): > def __getitem__(self, index): > super_ = super(ARRAY_D.Comparator, self).__getitem__(index) > if not isinstance(index, slice) and self.type.dimensions > 1: > super_ = type_coerce( > super_, > ARRAY_D( > self.type.item_type, > dimensions=self.type.dimensions - 1, > zero_indexes=self.type.zero_indexes) > ) > return super_ > comparator_factory = Comparator > > > > > *1-D array* > > wave = Column(ARRAY_D(Float, zero_indexes=True)) > > SQL > > | > > selectw.wavelength[17]fromdatadb.wavelength asw; > > wavelength > > ------------ > > 3634.96 > > (1row) > > | > > > > ORM - instance and class side > > | > > wave =session.query(datadb.Wavelength).first() > > wave.wavelength[16] > > 3634.96 > > > > session.query(datadb.Wavelength.wavelength[16]).one() > > (3634.96) > > | > > > > > > *2-D array* > > value = Column(ARRAY_D(Float, dimensions=2, zero_indexes=True)) > > SQL > > || > > | > > selecte.value[17][18]from dapdb.emline ase limit 1; > > > > value > > ------------------- > > 4.962736845652115 > > | > > > > ORM - instance and class side > > || > > | > > # correct value on instance side > > emline=session.query(dapdb.EmLine).first() > > emline.value[16][17] > > 4.962736845652115 > > > > # expected correct indexing - wrong value > > session.query(dapdb.EmLine.value[16][17]).first() > > (4.8138361075679565) > > > > # both "1-indexed" - wrong value > > session.query(dapdb.EmLine.value[17][18]).first() > > (5.380134788537585) > > > > # first index is correct, but second is incremented by 1 - correct value > > session.query(dapdb.EmLine.value[16][18]).first() > > (4.962736845652115) > > | > > > > Cheers, Brian > > > > -- > >
-- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.