Merge pull request #3131 from ebean-orm/feature/h2-nonKeyWords

Modify ebean-test H2Database setup to default KEY,VALUE as non-keywords
This commit is contained in:
Rob Bygrave
2023-07-11 12:49:15 +12:00
committed by GitHub
3 changed files with 20 additions and 2 deletions
@@ -28,6 +28,11 @@ public class Person extends EBase {
String notes;
/**
* Test that KEY and VALUE are now by default not h2database keywords.
*/
String key;
public Person(String name) {
this.name = name;
this.status = Status.NEW;
@@ -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();
}