-
Notifications
You must be signed in to change notification settings - Fork 53
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
Add support for Jooqs YearToSecond #220
Comments
Can you provide a sample table definition or a reproducer? |
Sorry for late reply, haven't seen your question.
create table maintenance
(
maintenance_id integer generated by default as identity
primary key,
last_edit_timestamp timestamp with time zone default now() not null,
maintenance_interval interval
); var dao = MaintenanceDao(...);
var maintenance = Maintenance(null, OffsetDateTime.now(), YearToSecond(YearToMonth(0,1), DayToSecond(0,0,0)));
dao.insertReturningPrimary(maintenance); <plugin>
<!-- Specify the maven code generator plugin -->
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>${jooq.version}</version>
<!-- The plugin should hook into the generate goal -->
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgres.version}</version>
</dependency>
<dependency>
<groupId>io.github.jklingsporn</groupId>
<artifactId>vertx-jooq-generate</artifactId>
<version>${vertx-jooq.version}</version>
</dependency>
</dependencies>
<configuration>
<configurationFile>${jooq.config}</configurationFile>
<jdbc>
<driver>${database.driver}</driver>
</jdbc>
<!-- Generator parameters -->
<generator>
<name>io.github.jklingsporn.vertx.jooq.generate.classic.ClassicReactiveVertxGenerator
</name>
<!-- use 'io.github.jklingsporn.vertx.jooq.generate.classic.ClassicReactiveGuiceVertxGenerator' to enable Guice DI -->
<database>
<name>org.jooq.meta.postgres.PostgresDatabase</name>
<includes>.*</includes>
<forcedTypes>
<forcedType>
<userType>io.vertx.core.json.JsonObject</userType>
<converter>
io.github.jklingsporn.vertx.jooq.shared.postgres.JSONToJsonObjectConverter
</converter>
<expression>data</expression>
<types>(?i:JSON)</types>
</forcedType>
</forcedTypes>
<unsignedTypes>false</unsignedTypes>
</database>
<target>
<packageName>${jooq-generated.package}</packageName>
<directory>${jooq-generated.dir}</directory>
</target>
<generate>
<javaTimeTypes>true</javaTimeTypes>
<interfaces>true</interfaces>
<daos>true</daos>
<fluentSetters>true</fluentSetters>
</generate>
<strategy>
<name>io.github.jklingsporn.vertx.jooq.generate.VertxGeneratorStrategy</name>
</strategy>
</generator>
</configuration>
</plugin> |
I tested the generated jooq sql query and copied it to the sql console, then it worked. I also think the vertx-jooq code generator can support the datatype by mapping the fields of pg-client Interval to the Jooq YearToSecond instance: import io.vertx.pgclient.data.Interval
import io.vertx.sqlclient.Row
var row = Row();
var interval = row.get(Interval.class, position/column);
obj.value = new YearToSecond(new YearToMonth(interval.year, interval.month), new DayToSecond(...)); |
@jklingsporn can you say something new? |
What't interesting: while for example there exists a method |
I think this comes from the point that Interval is not supported in all database drivers. |
As you've already mentioned, the |
Thank you, I will try to implement it following your example. I will give feedback when I'm done. |
Your example works, if the Interval type is the user type, but how I configure it to use jooqs YearToSecond instead? |
It seems that this comes from the supportedRowTypes in the current release, if I understand the code correctly. |
@jklingsporn can you create a new release containing this change? |
I'm really sorry for the late reply. Haven't forgot this and will craft a release as fast as I can ^^ |
Thank you, maybe you also have the time to check #223 😊 |
I want to use the postgres interval data type. Unfortunately is the value not written to the database. While debugging the query mapping, the build query is correct. But after execution there is nothing in the database. For the read case I understand if it is not supported and I could do the back-mapping by myself, but the write should work correctly because it relies only on existing jooq features.
The text was updated successfully, but these errors were encountered: