Skip to content
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

SimpleQuery vs Query with Date and UUID columns ? #70

Open
Phil89a opened this issue Jan 5, 2022 · 1 comment
Open

SimpleQuery vs Query with Date and UUID columns ? #70

Phil89a opened this issue Jan 5, 2022 · 1 comment
Assignees
Labels
bug Something isn't working
Projects

Comments

@Phil89a
Copy link

Phil89a commented Jan 5, 2022

Just wondering - if there is a difference in the way Date and UUID columns are handled between SimpleQuery and Query ?

If I run exactly the same SQL code in both, the SimpleQuery fails when trying to read a returned Date column; whereas Query reads the column fine.

Likewise, SimpleQuery correctly returns a UUID column, but Query fails to read the UUID and it has to be read as a .string.

Any ideas?

@gwynne gwynne added the bug Something isn't working label May 9, 2023
@gwynne gwynne added this to To Do in Vapor 4 via automation May 9, 2023
@gwynne
Copy link
Member

gwynne commented May 9, 2023

Apologies for the extremely late response to this issue 😕.

The problem is due to SimpleQuery using the old text-based protocol which sends values as part of the query itself and returns rows using the text resultset protocol, whereas Query uses the prepared statement binary protocol. MySQLNIO's current implementation only has Date decoding support for the binary protocol. While the UUID support does ostensibly support both protocols, the text protocol happens to be identical for UUIDs and strings, while the binary protocol entirely differs; there is no native UUID support in MySQL, and it ends up stored as either VARCHAR or VARBINARY. If a UUID was originally stored as a string, it has to be read back as one, and the current implementation can't tell the difference.

The MySQLNIO rewrite I've had in progress for roughly three or four ages of the universe at this point (#73) will robustly handle these situations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Vapor 4
  
To Do
Development

No branches or pull requests

2 participants