Bug #62061 Usinc \func line in inserts tab fields prevents Applying data changes
Submitted: 2 Aug 2011 19:07 Modified: 9 Aug 2012 7:40
Reporter: Adrian Sta„czak Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench Severity:S3 (Non-critical)
Version:5.2.34 OS:Any (Windows 7, Mac OS X)
Assigned to: CPU Architecture:Any

[2 Aug 2011 19:07] Adrian Sta„czak
Description:
When I click "Mark Field Value as Function" option in an INT type field the inserted line \func along with any added following content for eg: "\func DEFAULT" (without the quotation marks) prevents the "Apply changes to data" button from applying them. The "pending changes" message keeps appearing.

How to repeat:
Make a table and a column of any INTEGER type. Set a DEFAULT value for that column. Then go to inserts tab and make a new record. There in the proper field add a code: \func DEFAULT
Or any other proper function for that matter.
Then Click "Apply changes to data" button.
After that try to pick another table or even another Workbench pane. The "pending changes messages" keeps appearing without any indication that something went wrong, tough the changes are not applied.
There is never any indication whether the data change succeeds or fails, or why.

Suggested fix:
I would suggest checking if the "\" character is considered before or after checking if the field type is correct.
I understand this may not be a bug as such, because there is obviously no problem when the field type is text based, because the "\" character commands are only used in text fields.

However this still leaves the matter of inserting DEFAULT values int INT fields with Workbench. For leaving the cells empty makes Workbench insert NULL values instead of giving no values. The only way then is to edit the forward engineered file manually. Still it can be a lot of work whenever a file is created anew. 

I apologize if there is a way to do that. I haven't found one tough.
[2 Aug 2011 19:14] Adrian Sta„czak
Also after inputting a text into a field and then changing the column data type to a mismatching one (VARCHAR to INT) it causes Workbench to to lock out the inserts pane and act strangely other than that (including a slowdown and some graphic refreshing glitches).
[2 Aug 2011 19:20] Valeriy Kravchuk
Verified just as described. Indeed, \func is passed to server "as is", and this is wrong.

Had you tired to just type DEFAULT in the field to set default value there? Worked for me on Mac OS X.
[2 Aug 2011 19:27] Adrian Sta„czak
Doing so forced me to restart MySQL Workbench. After reloading the file the column contained text based value in an INT type field and everything worked fine. It allowed me to forward engineer such a table without any problems. The thing is that the \func DEFAULT was not the sole DEFAULT value but the whole \func DEFAULT and without any quotation marks.

Thus after that setting field type to VARCHAR and typing pasting DEFAULT (without the \func prefix) into the fields I needed and changing field values to INT, saving and restarting the workbench, surprisingly solved the problem completely to me.

Tough I imagine it was not supposed to work that way.
[2 Aug 2011 19:30] Adrian Sta„czak
I meant changing column type from VARCHAR to INT with DEFAULT inserted into the fields. It really does the trick.
[9 Aug 2012 7:40] Philip Olson
Fixed as of the upcoming 5.2.42, and here's the changelog entry:

Using "\func" would prevent the "Apply changes to data" option to function,
and instead "Pending changes" error message windows would be displayed.