jklingsporn/vertx-jooq

MariaDB support for lastInsertId

leavestylecode opened this issue · 8 comments

change to classic-reactive, call dao.insertReturningPrimary(obj) will throw UnsupportedOperationException().

I'm confused for that.

屏幕快照 2021-01-06 下午3 03 51

屏幕快照 2021-01-06 下午3 05 18

Hello,
can you please tell me more about your configuration? The method should be overridden by the code generator in the actual DAO-implementations (see this generated DAO from the tests). However this only happens if the configured dialect for code generation is Mysql.
This is the relevant part in the code generator:

if (schema.getDatabase().getDialect().family().equals(SQLDialect.MYSQL)) {
                    out.println();
                    out.tab(1).override();
                    out.tab(1).println("protected java.util.function.Function<io.vertx.sqlclient.RowSet<io.vertx.sqlclient.Row>,Long> extractMysqlLastInsertProperty(){");
                    out.tab(2).println("return rs -> rs.property(io.vertx.mysqlclient.MySQLClient.LAST_INSERTED_ID);");
                    out.tab(1).println("}");
                }

My db is mariadb, so how can I fix that?

For now you would need to fork the generate-module and change the VertxGeneratorBuilder like this:

if (schema.getDatabase().getDialect().family().equals(SQLDialect.MYSQL) || schema.getDatabase().getDialect().family().equals(SQLDialect.MARIADB)) {
                    out.println();
                    out.tab(1).override();
                    out.tab(1).println("protected java.util.function.Function<io.vertx.sqlclient.RowSet<io.vertx.sqlclient.Row>,Long> extractMysqlLastInsertProperty(){");
                    out.tab(2).println("return rs -> rs.property(io.vertx.mysqlclient.MySQLClient.LAST_INSERTED_ID);");
                    out.tab(1).println("}");
                }

Or wait until I've implemented it.

I can wait 6.1.0 to use that😁

Should be available on maven central. Please let me know if it works for you.

Nice, It worked. 👏👏👏

When will 6.1.0 be released ? Handsome man 😅