Add ANSI_QUOTES propety to DBI init in lookups. (#13826)

This commit is contained in:
Abhishek Radhakrishnan 2023-02-21 15:13:22 -08:00 committed by GitHub
parent 8595271b55
commit 9e9976001c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 2 deletions

View File

@ -40,6 +40,7 @@ import org.skife.jdbi.v2.util.TimestampMapper;
import javax.annotation.Nullable;
import java.sql.Timestamp;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@ -191,10 +192,21 @@ public final class JdbcCacheGenerator implements CacheGenerator<JdbcExtractionNa
dbi = dbiCache.get(key);
}
if (dbi == null) {
Properties props = new Properties();
if (namespace.getConnectorConfig().getUser() != null) {
props.setProperty("user", namespace.getConnectorConfig().getUser());
}
if (namespace.getConnectorConfig().getPassword() != null) {
props.setProperty("password", namespace.getConnectorConfig().getPassword());
}
// We use double quotes to quote identifiers. This enables us to write SQL
// that works with most databases that are SQL compliant.
props.setProperty("sessionVariables", "sql_mode='ANSI_QUOTES'");
final DBI newDbi = new DBI(
namespace.getConnectorConfig().getConnectURI(),
namespace.getConnectorConfig().getUser(),
namespace.getConnectorConfig().getPassword()
props
);
dbiCache.putIfAbsent(key, newDbi);
dbi = dbiCache.get(key);