Modify ebean-test H2Database setup to default KEY,VALUE as non-keywords

H2Database 2.x changed KEY and VALUE to be deemed keywords for SQL compliance. This is actually a bit of a pain as all the other databases we test allow KEY and VALUE as column names.

This changes the setup for H2Database to treat KEY and VALUE as non keywords as before and be more consistent with the other databases.
This commit is contained in:
Rob Bygrave
2023-07-05 23:46:06 +12:00
parent ffc21daaba
commit 1e860112e6
3 changed files with 20 additions and 2 deletions
@@ -50,6 +50,16 @@ class Config {
this.properties = config.getProperties();
}
/**
* Return the property given the key and default value.
*/
String property(String key, String defaultValue) {
if (properties == null) {
return null;
}
return properties.getProperty(key, defaultValue);
}
void setSchemaFromDbName(String newDbName) {
this.schema = databaseName;
this.databaseName = newDbName;
@@ -6,14 +6,17 @@ class H2Setup implements PlatformSetup {
@Override
public Properties setup(Config config) {
config.ddlMode("create");
config.setUsername("sa");
config.setPassword("");
config.setUrl("jdbc:h2:mem:${databaseName}");
config.setDriver("org.h2.Driver");
config.datasourceDefaults();
var dataSourceConfig = config.datasourceDefaults();
String nonKeyWords = config.property("ebean.test.nonKeywords", "KEY,VALUE");
if (!nonKeyWords.isBlank()) {
dataSourceConfig.addProperty("NON_KEYWORDS", nonKeyWords);
}
// return empty properties
return new Properties();
}