Thanks Rick, I updated to the latest SVN rev and things do work now.
Cheers, François On Apr 4, 10:08 pm, "Rick Morrison" <[EMAIL PROTECTED]> wrote: > Hi fw, > > The explicit zero for the > float column was a bug that should be fixed in rev #2491. > > MSSQL can store low-resolution datetimes in DATE columns, and the format for > MSSQL Date columns was expanded to allow storing those (note the missing > seconds in the format). > > That date change should not affect your queries -- does it? > > On 4/4/07, fw <[EMAIL PROTECTED]> wrote: > > > > > Hi list, > > > I am using a mssql database. > > > A mapper that was working in 0.3.4, no longer works in 0.3.6, > > > The query built is apparently the same, but the values used as > > parameters are not the same. > > > Under 0.3.4 it was > > INFO sqlalchemy.engine.base.Engine.0x..d0 {'lazy_fa2e': 'xxxxx', > > 'MakerCost_MakerCost': '0', 'MakerCost_Effective_Date': '2007-04-04'} > > > Under 03.6 it has become > > INFO sqlalchemy.engine.base.Engine.0x..d0 > > {'MakerCost_MakerCost': None, 'lazy_e4bf': 'xxxxx', > > 'MakerCost_Effective_Date': '2007-04-04 00:00'} > > > As you can see MakerCost has become None instead of 0 (zero) and the > > Date has turned into a Datetime. Note that the 0 (zero) is explicitly > > specified in a query. > > > What is going on? Any pointer appreciated. > > > TIA > > François > > > Here are the gruesome details > > > The MakerCost table associate the Maker and the Model tables. It also > > has a "Cost" and a "Date" fields. > > > The mapped "Cost" property retrieves only the "current" cost. It is > > when using the "Cost" property that the problem occurs (In the info > > above, the "Cost" property on a "Maker" object) > > > tblMaker=Table("Maker", > > Column("MAKERCODE",StripString, primary_key = True), > > Column("NAME" , CP874String,nullable=False), > > Column("ADDR0",String(40),nullable=True), > > Column("ADDR1",String(40),nullable=True), > > Column("ADDR2",String(40),nullable=True), > > Column("ADDR3",String(40),nullable=True), > > Column("TBCODE",String,nullable=False), > > Column("CONTACT",String,nullable=False), > > Column("COMMENTS",String), > > Column("DSTAMP",DateTime), > > Column("USERNAME",String(8))) > > > tblModel=Table("Model", > > Column("ModelCode",CodeString(20), primary_key = True), > > Column("ModelGroup",String(12),nullable=False), > > Column("ModelThaiName",CP874String(50),nullable=False), > > Column("ModelEnglishName",StripString(50),nullable=False), > > Column("ModelWeight",Float), > > Column("UnitCode",String(5)), > > #Column("ProductGroupCode",ForeignKey("... TODO > > Column("ModelRemark",CP874String(50)), > > Column("EffectDate",Date), > > Column("LastDate",DateTime), > > Column("LastUser",String(8))) > > > tblMakerCost=Table("MakerCost", > > Column("RowOrder",Integer, primary_key = True), > > Column("MakerCode" , StripString(50),ForeignKey("Maker.MAKERCODE > > ")), > > Column("ModelCode" , CodeString,ForeignKey("Model.ModelCode")), > > Column("MakerCost",Float,nullable=False), > > Column("Remark",CP874String(100)), > > Column("Reference",CP874String()), > > Column("Effective_Date",Date), > > Column("LastUpdate",DateTime), > > Column("LastUser",String(8))) > > > MakerCost.mapper["Primary"]=mapper(MakerCost,tblMakerCost, > > properties={ > > 'Cost': tblMakerCost.c.MakerCost, > > 'id':tblMakerCost.c.RowOrder, > > } > > ) > > > #Getting only the latest costs > > sCCSub=select([tblMakerCost.c.MakerCode, tblMakerCost.c.ModelCode, > > func.max(tblMakerCost.c.Effective_Date).label('Effective_Date')], > > tblMakerCost.c.Effective_Date<=datetime.date.today(),group_by=[ > > tblMakerCost.c.MakerCode, > > tblMakerCost.c.ModelCode]).alias('sCCSub') > > > sCurrentCost=select([c for c in > > tblMakerCost.c],tblMakerCost.c.MakerCost > > >0,from_obj=[join(tblMakerCost,sCCSub,and_( > > sCCSub.c.MakerCode==tblMakerCost.c.MakerCode,and_( > > sCCSub.c.ModelCode==tblMakerCost.c.ModelCode, > > sCCSub.c.Effective_Date==tblMakerCost.c.Effective_Date > > )))]).alias('sCurrentCost') > > > Maker.mapper["Primary"]=mapper(Maker, tblMaker, properties={ > > 'AllCosts':relation(MakerCost, backref='Maker',lazy=True, > > cascade="all, delete-orphan"), > > 'Costs': relation(mapper(MakerCost,sCurrentCost, > > non_primary=True), > > uselist=True, viewonly=True), > > #Models': > > relation(Model,secondary=tblMakerCost,secondaryjoin= > > tblModel.c.ModelCode==tblMakerCost.c.ModelCode, > > > #primaryjoin=tblMaker.c.MAKERCODE==tblMakerCost.c.MakerCode,uselist=True, > > viewonly=True), > > 'Name':tblMaker.c.NAME, > > 'Code':tblMaker.c.MAKERCODE, > > 'Contact': tblMaker.c.CONTACT, > > 'Comment': tblMaker.c.COMMENTS, > > 'LastUpdate':tblMaker.c.DSTAMP, > > 'LastUser':tblMaker.c.USERNAME > > } > > ) > > > Model.mapper["Primary"]=mapper(Model,tblModel, properties={ > > 'AllCosts':relation(MakerCost,backref='Model',lazy=True, > > cascade="all, delete-orphan"), > > 'Costs': relation(mapper(MakerCost,sCurrentCost, > > non_primary=True), > > uselist=True, viewonly=True), > > 'Makers': > > relation(Maker,secondary=tblMakerCost,primaryjoin= > > tblModel.c.ModelCode==tblMakerCost.c.ModelCode, > > > secondaryjoin=tblMaker.c.MAKERCODE==tblMakerCost.c.MakerCode > > ,backref="Models",uselist=True, > > viewonly=True), > > 'Code':tblModel.c.ModelCode, > > 'Weight':tblModel.c.ModelWeight, > > 'Start_Date':tblModel.c.EffectDate, > > 'Products': relation(Product, backref='Model',lazy=True, > > cascade="all, delete-orphan"), > > } > > ) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---