[BUG]: DATETIME empty field not saved correctly. #1245
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What Happened?
If i create a non required datetime field using the OTHER (EMPTY) option for the db so the table matches how joomla saves datetime fields and there is no issue with newer mysql versions it does not save the field.
I get this error instead:
Save failed with the following error: Incorrect datetime value: '' for column
db_extension
.prefix_component_table
.publish_up
at row 1.In order to fix this issue i had to add this to my save method in the admin view:
The next issue that arrose is that it did not save an empty value. because in the store function of the src/Table/View.php it is saving using $updateNulls = false;
I have no idea how to override this. But if i hard code it to true at the top it did save the null value like it was supposed to do.
Hope we can sort out what needs to be done to support datetime using the null option.
Steps to reproduce the Bug
add a datetime field with db default value NULL (OTHER -> EMPTY) to an admin view.
try to save the admin view with no date present.
expected: to save without date.
result: error could not save it.
Which Joomla version are you compiling in?
5.3
Which PHP version are you compiling in?
8.3
Which Joomla versions are you targeting?
5.3
Which PHP version are you targeting?
8.3
Which Web server is JCB running on?
litespeed
Which Relational Database is JCB running on?
mariadb 10.11
Which OS is JCB running on?
almalinux 9
Which JCB version are you using?
5.1.1 stable
Where in JCB did this issue occur?
Admin View(admin_view)
On which browsers did you encounter the issue?
Firefox, Safari
Additional Comments
No response
T o get a field to save as null you must set the default to
EMPTY
like this:This will cause the field to behave as expected. We took this direction since leaving a default empty is an empty string.... be for it to be really empty, we opt for the
EMPTY
key word.... might need improvement, but it does the job.Yes i know that is exactly what i did. But joomla still tries to put an empty string in it. wondering maybe because i left default empty in the field params. i'll go check that.
Here are some screenshots of my field and my db settings of the field.
This was not the cause unfortunately.