Git Product home page Git Product logo

Comments (7)

gwynne avatar gwynne commented on June 11, 2024 2

Congratulations, incidentally, on opening the very first issue to be officially assigned to Fluent 5!

from fluent-mysql-driver.

vzsg avatar vzsg commented on June 11, 2024 1

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.

from fluent-mysql-driver.

gwynne avatar gwynne commented on June 11, 2024 1

It's also worth noting that with any of the SQL drivers (PostgreSQL, MySQL, SQLite), you're usually much better off using Int for your IDs rather than UUID - it's much smaller, much, MUCH faster, and has no meaningful drawbacks unless you expect to interoperate with a system which does use UUIDs for its identifiers. Fluent only defaults to using UUIDs because of MongoDB support, which Fluent 5 Will Not Have™. You can switch over by changing your @ID var id: UUID? (or @ID(key: .id) etc.) properties to @ID(custom: .id) var id: Int? in your models and using .field(.id, .int, .identifier(auto: true)) instead of .id() in your migrations (this also gives you the use of auto-increment primary keys, which is another minor speed win).

from fluent-mysql-driver.

gwynne avatar gwynne commented on June 11, 2024

This is normal behavior for the MySQL driver, unfortunately - UUIDs are stored as raw bytes, and the MySQL driver maps the .uuid type to VARBINARY(16), but the MySQL commandline and most other MySQL tools will attempt to read this as if it were just text with binary charset/collation (i.e. none); the result is the gibberish you're seeing. You can see results more like what you were expecting with a query of the form SELECT HEX(id) FROM table.

It is worth noting that the most recent versions of the mysql commandline monitor (8.3.0 or later) will display such data in a readable format without additional intervention.

(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.)

from fluent-mysql-driver.

advanc3dUA avatar advanc3dUA commented on June 11, 2024

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?:)

from fluent-mysql-driver.

gwynne avatar gwynne commented on June 11, 2024

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?

from fluent-mysql-driver.

advanc3dUA avatar advanc3dUA commented on June 11, 2024

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 :).

from fluent-mysql-driver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.