I would like to know if there's a notnull() function in sqlalchemy
similar to null()
to avoid things like not_(null()) ?
thank you
j
>
> Michael Bayer wrote:
>> why dont you just stick with None instead of "nn" ? then you just
>> write:
>>
>> if v is None:
>> clause.append(self.c.field != v)
>> else:
>> clause.append(self.c.field == v)
> It could be an idea but not intuitive and unnatural
>
> because None = IS NOT NULL (very ugly) :-(
> and null() = IS NULL
well the logic you're doing above seems unnatural all by itself, that
if v is NULL you want a NOT NULL. that would seem just as
"unnaturual" using "null()" as "None".
just make yourself a notnull = not_(null()) and problem solved.
>
>
>
>
> Michael Bayer ha scritto:
>> On Mar 19, 2009, at 12:34 PM, jo wrote:
>>
>>
>>> Michael Bayer wrote:
>>>
>>>> why dont you just stick with None instead of "nn" ? then you just
>>>> write:
>>>>
>>>> if v is None:
>>>> clause.append(self.c.field != v)
>>>> else:
>>>> clause.append(self.c.field == v)
>>>>
>>> It could be an idea but not intuitive and unnatural
>>>
>>> because None = IS NOT NULL (very ugly) :-(
>>> and null() = IS NULL
>>>
>>
>> well the logic you're doing above seems unnatural all by itself, that
>> if v is NULL you want a NOT NULL. that would seem just as
>> "unnaturual" using "null()" as "None".
>>
>> just make yourself a notnull = not_(null()) and problem solved.
>>
>>
> the hint you suggested me doesn't work because SQLAlchemy translate it
> to " = (NOT NULL) " which is invalid sql...
>
sqlalchemy produces IS NOT NULL using the != operator in conjunction
with None or null(). I don't see a reason to add another way of doing
the same thing.