Why this error occurs when adding a field to db.xml and refreshing the block?
Permalink
In a fit of inspiration I decided to...well...add a field to a table used by a block I am building :)
What could be easier than editing my db.xml file, adding a new field into the xml there, and then finding the block in the Dashboard, Editing it and doing a Refresh...right?
Well...it didn't quite work out that way.
I get the following error when I try that route and am wondering what this error is about?
[blockquote]
The following errors occurred when attempting to process your request:
mysql error: [1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1] in EXECUTE("ALTER TABLE blockPageThumbnail ADD thumbnail_alt_text VARCHAR")
[/blockquote]
Now I can get around this error by going to the table myself, adding the new field manually, and then Refreshing but being the hound that I am to try and understand why things are why...I am curious as to the cause of this error?
The ALTER statement in that query looks just fine and should work.
Is this a bug that I found or something else?
Anybody.
Carlos
What could be easier than editing my db.xml file, adding a new field into the xml there, and then finding the block in the Dashboard, Editing it and doing a Refresh...right?
Well...it didn't quite work out that way.
I get the following error when I try that route and am wondering what this error is about?
[blockquote]
The following errors occurred when attempting to process your request:
mysql error: [1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1] in EXECUTE("ALTER TABLE blockPageThumbnail ADD thumbnail_alt_text VARCHAR")
[/blockquote]
Now I can get around this error by going to the table myself, adding the new field manually, and then Refreshing but being the hound that I am to try and understand why things are why...I am curious as to the cause of this error?
The ALTER statement in that query looks just fine and should work.
Is this a bug that I found or something else?
Anybody.
Carlos
Where relevant I tend to add a size as a matter of course, just so I know exactly where I stand. It doesn't 'cost' anything to do so.
I'll do that JohntheFish. Good suggestion.
I guess I had just been following what I was seeing inside the db.xml files of various blocks where I had not seen any explicit size indications in their field definition (other than the implied size in the use of letters like "C", "X", and so on).
Kinda weird how those blocks, when installed, were no problem with respect to creating the fields correctly in the implied sizes.
It's only when I try and add a field through the db.xml schema without an explicit size designation that this type of error occurs.
I can work it around it so I won't bother trying to figure out why anymore but of course...someone unfamiliar with MySQL or what is going on overall when trying to add a field through db.xml is going to be...well...quite lost.
Carlos
I guess I had just been following what I was seeing inside the db.xml files of various blocks where I had not seen any explicit size indications in their field definition (other than the implied size in the use of letters like "C", "X", and so on).
Kinda weird how those blocks, when installed, were no problem with respect to creating the fields correctly in the implied sizes.
It's only when I try and add a field through the db.xml schema without an explicit size designation that this type of error occurs.
I can work it around it so I won't bother trying to figure out why anymore but of course...someone unfamiliar with MySQL or what is going on overall when trying to add a field through db.xml is going to be...well...quite lost.
Carlos
I ran the query inside my favorite MySQL utility (called adminer) and sure enough the same error got returned there too.
Apparently I have to place the width of the VARCHAR inside parantheses like so...
I thought a "C" type inside db.xml was assumed by Concrete5 to never be more than 255 characters long?
Do I have to explicitly indicate the length of fields in db.xml?
Here is the statement I used inside db.xml.
Carlos