In DAL.sqlhtml_validators, we have:
if field.unique:
requires.insert(0,validators.IS_NOT_IN_DB(db,field))
I wonder why IS_NOT_IN_DB is prepended rather appended to the list of
validators. Given that some of the validators may actually alter the value
to be inserted (e.g., CRYPT, IS_SLUG, IS_UPPER, IS_LOWER, CLEANUP), I would
think we would generally want IS_NOT_IN_DB to come last so it applies to
the actual value to be inserted (of course, there are cases where you might
want the opposite).
Anthony
On Tuesday, July 8, 2014 3:41:41 PM UTC-4, Paolo Valleri wrote:
>
> I found the issue. Since the format of the date field (same happens for
> the time field) is a text in sqlite we must postpone to the validator
> IS_NOT_IN_DB the validator IS_DATE.
> By setting:
> db.user_table.birthday.requires=[IS_DATE(), IS_NOT_IN_DB(db,
> 'user_table.birthday')]
> everything works as expected even on sqlite.
> What do you think if we make it as default for date/time fields when the
> backend is sqlite?
>
> Paolo
>
> On Tuesday, July 8, 2014 7:04:44 PM UTC+2, Paolo Valleri wrote:
>>
>> What is odd to me is that,on postgres the validator works as expected
>> while on sqlite it doesnât and it is the backend itself that raises the
>> exception.
>> On Jul 8, 2014 6:43 PM, "Anthony" <[email protected]> wrote:
>>
>>> Are you saying you want an error message to appear on the form? For
>>> that, you need an IS_NOT_IN_DB validator, regardless of the database
>>> backend.
>>>
>>> Anthony
>>>
>>> --
>>> Resources:
>>> - http://web2py.com
>>> - http://web2py.com/book (Documentation)
>>> - http://github.com/web2py/web2py (Source code)
>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>> ---
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "web2py-users" group.
>>> To unsubscribe from this topic, visit
>>> https://groups.google.com/d/topic/web2py/AnmLhKmS8UA/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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/d/optout.