Dan rejected the ticket. And I realized that I could not strenuously argue
for it, since it is not clear if an empty string means null or 0. So I have
this alternate suggestion:

   - Add a :blank_value option for Integer properties. When false, blank
   strings are rejected. When nil, blanks are mapped to nil. When 0, blanks are
   mapped to 0. The default would be false.

I added a comment to the ticket.

I do not know what AR's behavior is in this case. Does anyone know offhand?

Since the previous version of DM accepted blank strings for integer fields
and there is lots of code that depends on  this behavior, providing a
:blank_value option makes eminent sense to keep that code working.

..tony..

On Mon, Oct 12, 2009 at 2:27 PM, Tony Collen <[email protected]> wrote:

> (another Tony jumping into the discussion here)
>
> I guess it depends on your definition of "missing" -- I believe most
> browsers will generally submit all non-disabled fields.  And being able to
> accept a blank input field is very useful... often times you will just pass
> params[:whatever] directly down to the ORM level with minimal, if any web
> framework intervention.
>
> Say you have a form with a hidden field named "foo", and it's blank, e.g.
> <input type="hidden" name="foo" value="" />.
>
> You should get the string "" submitted to the framework.
>
> This is different from NOT having a that field in the form, because in the
> framework params[:foo] will generally be nil, indicating the value was not
> submitted.
>
> At one level, I could see the argument for it being the responsibility of
> the web framework, but this seems like expected behavior that was lost.
>
> Out of curiosity, what would AR do in this case?
>
>  - Tony
>
> On Mon, Oct 12, 2009 at 3:59 PM, Ashley Moran <
> [email protected]> wrote:
>
>>
>> This is a recurrent problem in webapps.  Browsers don't (and can't)
>> distinguish between a missing field and a blank string field.  I have
>> a gut feeling the data should be cleansed at the controller level.
>> But wherever, this is, IMHO, not an ORM problem, but a web framework
>> one.
>>
>>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to