MySQL Forums
Forum List  »  MySQL Workbench

Re: BLOB editor converts \func to NULL on forward engineering
Posted by: Michael Hoffmann
Date: January 31, 2021 03:59AM

Oh, I thought you wanted me to create a Python script via the Scripting Shell. Ok. Then...

1. [File]-[New Model]

2. [Model]-[Add Diagram]

3. [Place a new table called "table1"]

4. Add column "idtable1" to new table
Column Name = idtable1
Datatype = BINARY(16)

5. Add column" test" to new table
Column name = test
Datatype = VARCHAR(45)

5. Change to tab "Inserts"

6. Double click on field in column "test" and type some letters

7. Right-click on field in column "idtable1" and select "Mark Field Value as Function/Literal"

8. Right-click again on field in column "idtable1" (now being displayed as "BLOB") and select "Open Value in Editor"

9. In dialog "Edit Data" change Text from "\func" to "\func UUID_TO_BIN(UUID())" an confirm with "Apply"

10. Back on "Inserts" tab apply changes with "Apply changes to data"

11. [Database]-[Forward Engineer]; use any existing database connection you have to a MySQL8 DB

12. Ensure you have "Generate INSERT statements for tables" checked

13. On screen "Review the SQL Script to be Executed" check the generated INSERT statement:

INSERT INTO `mydb`.`table1` (`idtable1`, `test`) VALUES (0x5C66756E6320555549445F544F5F42494E2855554944282929, 'aa');

Please note that the value for idtable1 is not a valid BINARY(16)

14. Click "Next" to start execution of the generated SQL script

15. Error occurs
"Executing SQL script in server.
ERROR: Error 1406: Data too long for column 'idtable1' at row 1"

Seems like the function specified in the value of field "idtable1" does not get executed but just converted to BINARY. Please note that the value of field "idtable" provided in the inserts tab is actually 25 bytes long; exactly the same length as the number of bytes in the generated SQL statement.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: BLOB editor converts \func to NULL on forward engineering
484
January 31, 2021 03:59AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.