Hi

I am having a problem with bizobj dataset getting data from a SQLite 
database.

The data field holds monetary amounts and is defined as type 'Real'.

If the table if the primary DataSource this field is held as a Decimal 
in the dataset, but if the table is joined to the main table, then it is 
held as a Float in the Dataset.

I list below a simple program I've constructed to illustrate the 
problem, followed by the output I get from running it.

This is causing problems because you can't mix these types in arithmetic 
operations, and I didn't want to resort to type converting all fields 
retrieved from the database.

Dave Nation

-------------------------------------------------------------------------------------------------------------------
import dabo
import decimal

def main():
    print dabo.version
    conn = dabo.db.dConnection(MyConnection())
   
    bizobj = OrderLinesBizobj(conn)
    bizobj.requery()
    bizobj.moveToRowNumber(0)
    rec = bizobj.Record
    packCost=rec.PackCost
    print '1. packCost',type(packCost)

    bizobj2 = ProductBizobj(conn)
    bizobj2.requery()
    bizobj2.moveToRowNumber(0)
    rec = bizobj2.Record
    packCost=rec.PackCost
    print '2. packCost',type(packCost)

class OrderLinesBizobj(dabo.biz.dBizobj):
    def afterInit(self):
        self.DataSource = "OrderLines"
        self.KeyField = "ID"
        self.addField("OrderLines.ID")
        self.addField("Product.PackCost")
       
        self.setJoinClause(" left outer Join Product on 
OrderLines.ProductID = Product.ID "  )
        self.setLimit("10")

class ProductBizobj(dabo.biz.dBizobj):
    def afterInit(self):
        self.DataSource = "Product"
        self.KeyField = "ID"
        self.addField("ID")
        self.addField("Product.PackCost")
        self.setLimit("10")

class MyConnection(dabo.db.dConnectInfo):
    def initProperties(self):
        self.DbType = "SQLite"
        self.Database = "c:\OrderBook\Data\OrderBook.db3"

if __name__ == '__main__':
    main()
-------------------------------------------------------------------------------------------------------------------



c:\OrderBook>python DeliveryTest.py
{'file_revision': '3673', 'version': '0.8.2', 'revision': '3673'}
1. packCost <type 'float'>
2. packCost <class 'decimal.Decimal'>

c:\OrderBook>
-------------------------------------------------------------------------------------------------------------------



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/dabo-users/[EMAIL PROTECTED]

Reply via email to