Skip to content

Commit

Permalink
Fix deprecated jOOQ usage
Browse files Browse the repository at this point in the history
  • Loading branch information
chadlwilson committed Jul 17, 2023
1 parent 7a6f3f8 commit 5743472
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/main/java/com/thoughtworks/go/dbsync/DbSync.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.apache.commons.io.FileUtils;
import org.jooq.Record;
import org.jooq.*;
import org.jooq.conf.RenderNameStyle;
import org.jooq.conf.RenderNameCase;
import org.jooq.conf.SettingsTools;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -48,8 +48,8 @@

import static com.thoughtworks.go.dbsync.Util.comment;
import static com.thoughtworks.go.dbsync.Util.*;
import static org.jooq.conf.RenderNameStyle.AS_IS;
import static org.jooq.conf.RenderNameStyle.QUOTED;
import static org.jooq.conf.RenderQuotedNames.EXPLICIT_DEFAULT_QUOTED;
import static org.jooq.conf.RenderQuotedNames.NEVER;
import static org.jooq.impl.DSL.*;
import static org.jooq.tools.StringUtils.isBlank;

Expand Down Expand Up @@ -373,6 +373,7 @@ private void executAndLogInsertStatement(String table, DataSource targetDataSour
InsertValuesStepN<Record> insertQuery = insertInto(table(table), fields);

for (Record record : records) {
//noinspection ResultOfMethodCallIgnored
insertQuery.values(record.intoArray());
}

Expand All @@ -384,10 +385,11 @@ private void executAndLogInsertStatement(String table, DataSource targetDataSour

private static DSLContext renderer(Connection targetConnection) {
Configuration targetConfiguration = using(targetConnection).configuration();
RenderNameStyle renderNameStyle = targetConfiguration.dialect().family() == SQLDialect.POSTGRES ? AS_IS : QUOTED;
return using(targetConfiguration.derive(SettingsTools.clone(targetConfiguration.settings())
.withRenderFormatted(false)
.withRenderNameStyle(renderNameStyle)));
.withRenderNameCase(RenderNameCase.AS_IS)
.withRenderQuotedNames(targetConfiguration.dialect().family() != SQLDialect.POSTGRES ? EXPLICIT_DEFAULT_QUOTED : NEVER)
));
}

@SuppressWarnings("resource")
Expand Down

0 comments on commit 5743472

Please sign in to comment.