-
-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Moving to MySQL causes UUID wrong behavior #222
Comments
This is normal behavior for the MySQL driver, unfortunately - UUIDs are stored as raw bytes, and the MySQL driver maps the It is worth noting that the most recent versions of the (Worth noting, this behavior will be fixed in Fluent 5, but in the meantime, it's normal and expected, and nothing is wrong with your setup.) |
Congratulations, incidentally, on opening the very first issue to be officially assigned to Fluent 5! |
Well, as a workaround I can create UUID, convert it into the String, and store it in the DB as String but not the UUID type. I need it in both directions - store and get from the table inside the app. Sounds like a plan?:) |
I'm not sure I follow - are you encountering an issue on the Fluent side, something beyond the inarguably annoying fact that the UUIDs don't usually display properly if you look at the database directly? |
UDIDs are saving wrong; they are wrong when I open the DB in DBeaver (DB viewer). Even in the _fluent_migrations table which I don't even know how to touch by myself: all added rows in it (my migrations) have wrong IDs. The UUIDs are stably wrong everywhere :). |
But they aren't "wrong", they're just in binary form. As gwynne already mentioned, if you want to prettify it, you could use the HEX or even the BIN_TO_UUID function in your SQL queries in DBeaver. Your application will still behave correctly with them if you use UUID in your Swift code. |
It's also worth noting that with any of the SQL drivers (PostgreSQL, MySQL, SQLite), you're usually much better off using |
Describe the bug
Hey, guys,
During the deployment of my app to the server, I decided to drop docker (because its minimum system requirements are 4GB of RAM while I want to use a cheaper server with less RAM) and change to MySQL DB. I successfully connected the app with DB, it compiles, starts, etc.
But there is a strange problem with UUID types. Before moving to MySQL the app was working pretty fine - my UUIDs were successfully generated before adding an object in the DB. Now I do get something like "ùïðé¡ Eô + u:Bh " instead of normal UUID in the id cell of the table.
More to the point, the table _fluent_migrations also has the same style of corrupted IDs of the applied migrations. So, looks like that is a global problem of my app and not because I set the wrong type for the field in the table.
How can I get the UUIDs back to normal behavior when I use MySQL?
To Reproduce
Same behavior on MacOS and Ubuntu. The only requirement is to use MySQL.
Expected behavior
I expect to get F9EFF0E9-A19D-45F4-862B-1D753A426898 this kind of UUIDs in the MySQL table instead of ùïðé¡ Eô + u:Bh ".
Environment
Additional context
I am working on my first Vapor project. So, I mean, I am a newbie and this can be not a bug but my low skill. In this case please help me to fix it.
The text was updated successfully, but these errors were encountered: