I suspect this is probably unique to me. Can you point me to the code?
I've looked in tools.py and dal.py but I can't find the exact spot where
Python True becomes 'T'.
All the inserts were done using grid or SQLFORM.
Here is the output from psql:
is_active | character(1) |
Notice there's no default for is_active.
Here is the select that was failing.
This is the only table I have where is_active isn't boolean.
Here's the failing query, but I don't think it will tell us anything.
Using _lastsql, I could see that it was clearly looking for a 'T' in
is_active.
rows = db(db.customer_order.customer_id==customer_id).select(
db.customer_order.id, db.customer_order.created_on,
db.customer_order_products.id,
join = [
db.customer_order_products.on(
db.customer_order_products.customer_order_id==
db.customer_order.id,
),
]
)
On Thursday, May 23, 2013 11:06:19 PM UTC-4, Massimo Di Pierro wrote:
>
> This is a backward compatibility issues. The fact that it inserts a 't'
> instead of a 'T' is more of a concern to me. How was the query built?
>
> The source clearly says:
> TRUE = 'T'
> FALSE = 'F'
>
> On Thursday, 23 May 2013 16:21:18 UTC-5, Cliff Kachinske wrote:
>>
>> auth.signature appends a "boolean" field called is_active to a table.
>> The default is True.
>>
>> Under the covers it's not really boolean, it's char(1). When you insert
>> a record, is_active is set to "t". That's right, a lowercase t.
>>
>> Today I had the kind of problem where queries were missing records. It
>> turns out that the DAL was emitting queries looking for 'T' in is_active.
>>
>> The queries were missing records because Postgres is case sensitive in
>> char fields.
>>
>> I don't really understand why the dal adapters for Postgres transmogrify
>> boolean fields to char(1) when Postgres supports boolean fields. The nice
>> thing about that is Postgres boolean fields do not care about case.
>>
>> The easy fix for this problem is make sure that any fields you have
>> defined as boolean in your models are also boolean in Postgres.
>>
>
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.