CRUDlex icon indicating copy to clipboard operation
CRUDlex copied to clipboard

EntityDefinition@getField $default parameter should not be null

Open planeth44 opened this issue 7 years ago • 5 comments

when you submit a form and fields are not required –if the type is text– the values are an empty string. the getField function replace these empty string value by a null value which breaks the SQL schema of NOT NULL if the definition is VARCHAR

planeth44 avatar Jul 03 '18 09:07 planeth44

Hi, the idea of the required-flag is to reflect the NOT NULL constraint. It is called "required" due to the possibility to have non SQL-implementations. My practice is: required = true -> NOT NULL required = false -> NULLABLE Setting empty strings to NULL here is just a choice because I can't decide whether the user wants NULL or empty string with just an input field. A specific use case would be very good where this scheme breaks. I could then think about how an UI supporting the difference between null and empty string could look like.

philiplb avatar Jul 03 '18 09:07 philiplb

This makes sense. My workaround is to make my custom MySQLDataFactory so I can add a ‘resetToBlank‘ function when calling ‘setValuesAndParameters’. Is there a better way?

As for a suggestion, could you make it a parameter –blank is empty string– in the MySQLDataFactory just like the useUUIDs?

planeth44 avatar Jul 03 '18 11:07 planeth44

Adding a flag to the field in the YAML is a good idea, I will do that. Right after the release of 0.14.0 which abstracts out the framework and then there are packages for framework implementations, Silex and Symfony for now. Reason: Silex is end of live. :(

philiplb avatar Jul 03 '18 11:07 philiplb

👍 Looking forward to the release of 14.0. Any ETA?

planeth44 avatar Jul 03 '18 11:07 planeth44

Mainly writing documentation is left. We are currently porting a bigger project to symfony4 and as soon as this works completly, I can be sure that the abstractions are fine.

philiplb avatar Jul 03 '18 11:07 philiplb