Skip to content

feat: fix MySQL +8.0 information_schema changes#2

Merged
LeadcodeDev merged 1 commit intoLeadcodeDev:mainfrom
green-new:fix/mysql-info-schema
May 3, 2026
Merged

feat: fix MySQL +8.0 information_schema changes#2
LeadcodeDev merged 1 commit intoLeadcodeDev:mainfrom
green-new:fix/mysql-info-schema

Conversation

@green-new
Copy link
Copy Markdown
Contributor

MySQL's information_schema in >=8.0 likely changed how the data from the table is transferred over the wire. Here I use String::from_utf8 to attempt to manually convert the tuples in each row of the "fetch_tables" function in mysql.rs. I was getting the error below while using the script:

Error: Database(ColumnDecode { index: "0", source: "mismatched types; Rust type `alloc::string::String` (as SQL type `VARCHAR`) is not compatible with SQL type `VARBINARY`" })

this implies that the previously used (String, String...) tuple converting each row in the result set was trying to convert a VARBINARY on the wire to a String, which is unexpected.

I think this solution might be more generalized and useful for different MySQL versions, only issue however is that I am not sure what MySQL uses for encoding of its internal tables and schemas, but this worked for me.

Previously it was successfully running the script, but generating no tables:

This is because of another issue with the MySQL usage where it uses the args.db.schema array, but it is default to an array of ["public"] and not using the schema defined in the database URL, requiring you to use the --schemas argument instead with no schema defined in the --database-url argument.

tristen@xxx:~/proj$ sqlx-gen generate entities --database-url mysql://root:root@127.0.0.1:3306/tenant
[2026-05-03T16:39:53Z INFO  sqlx_gen] Connecting to MySQL database...
[2026-05-03T16:39:53Z INFO  sqlx_gen] Found 0 tables, 0 views, 0 enums, 0 composite types, 0 domains
[2026-05-03T16:39:53Z INFO  sqlx_gen::writer] Wrote src/models/[mod.rs](http://mod.rs/)
[2026-05-03T16:39:53Z INFO  sqlx_gen] Done! Generated 1 files.

@LeadcodeDev
Copy link
Copy Markdown
Owner

Thank you for your contribution and for the email received 👀

@LeadcodeDev LeadcodeDev merged commit bacb088 into LeadcodeDev:main May 3, 2026
@LeadcodeDev LeadcodeDev added the enhancement New feature or request label May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants