I was working with a particularly large table (22 fields) and those fields are not always filled on create. In fact on first create, only 9 fields are set.
I was not surprised to get an error that I’m trying to create a row with undefined fields which don’t have default values. I saw two ways of fixing this:
- Go in the database and set every field to have default value set to
null - When calling
create, insert""for string values,0for integer values, etc.
I decided to go with the first option as it is quicker and less messy.
Now I have to go in the database and change each field to have default value of either null or current timestamp if working with date or time.
Is this really the best approach? Is there no way of leaving these fields empty?