Wybo Dekker wrote:
> In my mysql database I stored empty strings as NULL's, so that I can test
> fields to be nil.
>
> (It's shorter, nicer and more logical to test "if field" rather than
> "if field == ''")
>
> But when I edit a record, all NULL's in char fields are replaced with an
> empty string ('').
>
> Is there a way to prevent this?
> Or is my idea wrong in the first place?

I think the most simple and semantic way of going about it would be to
store empty fields as empty strings and use "if field.empty?" to
determine whether there's anything there. You should be able to convert
empty fields to nil in your update method, though, if you want to go
about it that way.