On 8/26/10 7:09 AM, Adrian Klaver wrote:
> On Thursday 26 August 2010 7:01:52 am Paul McNett wrote:
>> On 8/26/10 5:07 AM, Ed Leafe wrote:
>>> On Aug 26, 2010, at 8:03 AM, Henning Hraban Ramm wrote:
>>>>>> SQLite doesn't know a real Boolean type, but uses integers.
>>>>>> The SQLite backend should take care of that - seems like it doesn't.
>>>>>
>>>>> Being fairly wet-behind-the-ears on this stuff... which backend are
>>>>> you
>>>>> referring to?  sqlite to python, or dabo?
>>>>
>>>> I don't know, could be in Python's sqlite3 module or in dabo's
>>>> backend. I presume the latter, but didn't check.
>>>
>>>     Generally, the dbapi adapter (sqlite3 in this case) is supposed to do
>>> the translation between Python types and what the database expects.
>>> Dates/datetimes are the most typical place where this translation is
>>> needed, but booleans are also in need of translation when the database
>>> does not have a native boolean type.
>>
>> SQLite, the database, doesn't really know anything about data types at all.
>> As far as it is concerned, it really just stores bits and bytes.
>> Furthermore, you don't need to specify a type when defining a field:
>> whatever you name it is fine. Therefore, the pysqlite adapter could, at
>> best, guess at the intended python type to convert to based on conventional
>> field types like "INT", "CHAR", "DATE", "BOOL", etc.
>>
>> This fact is the main reason I added the DataSource property, so that I
>> could explicitly tell Dabo, at the bizobj level, when the appropriate
>> python types for each field are.
>>
>> Paul
>
> I am going to go out on a limb and say you meant DataStructure:)

Oops, yes you are correct. Thanks for the catch!


> For the record the below is the code in dbSQLite.py that handles boolean 
> values.
>
> def formatForQuery(self, val, fieldType=None):
>      if isinstance(val, bool):
>        return ustr(int(val))
>      else:
>        return super(SQLite, self).formatForQuery(val, fieldType)

Yes, I was really talking about sqlite and pysqlite, not the Dabo sqlite 
wrappers. If 
Dabo thinks the column is boolean, it'll convert True to "1" and False to "0", 
even 
if in your table you wanted True and False to be "T"/"F" or "Y","N".

Paul


_______________________________________________
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/[email protected]

Reply via email to