Date field throwing an error #252
Labels
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: joomla/Component-Builder#252
Loading…
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?
Steps to reproduce the issue
I've been using the date field
I've mimicked the demo date field but it throws an error not on install but when I try to install the component.
I've tried lots of variations but it just throws an error on installation :(
Expected result
expected it to create a table with the date as a field
Actual result
it throws an error
Worth noting that the date field is actually set to null (it wasn't initially)
System information (as much as possible)
Additional comments
I had the exact problem with another field and I had to uninstall the component and then it installed no problem.
System information (as much as possible)
This will help, since I have no idea where you are running this.
This is a mysql issue, you will see there has been some discussion about this on the forum.
I am not sure how we can address this, at this time.
OS Name & Version: Windows 10
MySql Version: 5.7
Apache Version:
PHP Version: 7.0.28
Joomla Version: 3.8.5
JCB Version: 2.6.17
Browser: CHrome
sorry I forgot them !
So I removed the view with the date field but the compiler is still trying to add the view(table) is there a way to force the compiler to do a fresh compile?
Okay, so you have not watched all the tutorials... I can point in the direction. But hey you will have to be willing to do the work of watching all the tutorials.
Basically you need to open Component Updates and change the SQL values there, since they get created automatic but are not removed automatic.
You could also uninstall and reinstall the component, the above dynamic generated SQL update scripts will then not run... but it is always good to keep an eye on this area if you change things.
Thank you for pointing me in the right direction. I thought I'd write up how I solved my problem - I hope it helps someone.
First there is a video about component updates - worth watching.
Joomla has a system where it searches for and reads an sql update file on install ( the video explains this). In any component over time many of these files will created, generally one for each new release of the component. Joomla uses version_compare on these files and runs any that haven't already been run.
This is a good thing since it ensures that a component is always up to date. However in development it has an unforeseen (at least by me) consequence.
In my case I created a new date field with NOT NULL and DEFAULT '' - I simply used the defaults in component builder and didn't check - my bad! This however throws an error for mysql since default cannot be empty. So I realised this and deleted the field and went to compile again. But it kept throwing the same error.
This is a consequence of the compare function that Joomla runs. Although I had removed the field and tried to reinstall Joomla was still trying to run the previous sql file. So my sequence went like this:
sql ver 1.0
Install component - all working lots of time saved
Add new view (new sql table) with date field
Compiler creates
sql ver 1.1
this sql attempts to create a table with a date value that doesn't work and component doesn't install
Delete the field
Compiler creates
sql ver1.2
when attempting to install joomla throws an error because it sees sql ver 1.1 hasn't been installed and so tries to install it which of course fails!
The only way to resolve this it to manually adjust the sql ver 1.1 file and add in DEFAULT '0000-00-00'. I did this by adjusting as shown in the video. You can't just delete the field - it doesn't work!
Hope this helps
Great, thanks for the feedback 👍