-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Creating tables using DSLContext.ddl() converts VARBINARY columns to TEXT in MySQL #9473
Comments
Thank you very much for your report. This issue was introduced by #6745 It seems we're generating the This can be demonstrated with: public static void main(String[] args) {
System.out.println(DSL.using(SQLDialect.MYSQL)
.createTable("t")
.column("b", BINARY)
.column("v", VARBINARY));
} Yielding: create table `t`(
`b` text null,
`v` text null
) However, this: public static void main(String[] args) {
System.out.println(DSL.using(SQLDialect.MYSQL)
.createTable("t")
.column("b", BINARY(256))
.column("v", VARBINARY(256)));
} Produces the wanted result: create table `t`(
`b` binary(256) null,
`v` varbinary(256) null
) So, a workaround would be to put a length in your CREATE TABLE `TestTable`
(
`Foo` BINARY(256),
`Bar` VARBINARY(256)
) |
When fixing this similar to #6745, we should generate the |
Fixed in jOOQ 3.13.0. Backport scheduled for 3.12.3 (#9477) (due today). |
This issue once more shows that we need to increase the priority of better data type management. Historically, we got away with what we have, because at runtime, more precise data type mappings are hardly needed. Even But in DDL statements, we must be able to express data types, including vendor specific types, in a much more precise manner. We currently can't do that, e.g. we currently cannot do better than generating |
Thanks for the quick turnaround. It may be a separate issue, but there is one other thing I'd like to note: the CREATE TABLE `TestTable`
(
`Foo` BINARY(256),
`Bar` VARBINARY
) And here's the generated declaration for the public final TableField<TesttableRecord, byte[]> FOO = createField(DSL.name("Foo"), org.jooq.impl.SQLDataType.VARBINARY, this, ""); I think this looks like a problem with the |
Thanks, @trdesilva: Indeed, it's always a good idea to create new issues if they're not strictly related, e.g. in order to track them. Your comment almost got lost in my inbox without ever being in any issue report. If the issue persists, would you mind creating a new issue? |
Behavior:
When creating tables with DSLContext.ddl(), columns with type SQLDataType.VARBINARY are instead created with type TEXT in the database. I expect the VARBINARY type to be preserved.
Repro:
See https://github.com/trdesilva/jOOQ-mcve
Versions:
The text was updated successfully, but these errors were encountered: