internetee / registry

TLD Management Software
Other
46 stars 19 forks source link

Consider normalizing empty values to NULL when inserting into the database #754

Open artur-intech opened 6 years ago

artur-intech commented 6 years ago

In Rails when saving a model from a form and values are not provided by the user, an empty string is recorded to the database instead of a NULL (mixing blanks and NULLs can become confusing).

virtualfeline commented 6 years ago

Do we actually have any case where missing value is acceptable ? Also consider that NULL returns different results than an empty string in queries. Will this affect smth? Are we sure we should prefer NULL?

artur-intech commented 6 years ago

@virtualfeline This is the default behaviour of Rails, if by missing value you mean empty string. I bet 99% of text columns in our database are empty if no value has been provided at the application level. I don't see production data so I cannot say how many of them are empty.

Also consider that NULL returns different results than an empty string in queries

Exactly! I am sure I want to see NULL when the data is missing or unknown, since this is the point of NULL. But is it worth the effort or not, is the topic of this ticket. If we leave it as is:

artur-intech commented 6 years ago

Example: #746 introduced contact reuse, so if one contact has fax value of "", and another of NULL, they will not be considered identical, and therefore will not be reused. @vohmar FYI

artur-intech commented 6 years ago