Skip to content

Commit

Permalink
Merge 167bccb into c6110ad
Browse files Browse the repository at this point in the history
  • Loading branch information
pbajoit committed Apr 9, 2019
2 parents c6110ad + 167bccb commit 9cbbbcd
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.jminiorm</groupId>
<artifactId>jminiorm</artifactId>
<version>0.0.24</version>
<version>0.0.26</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/jminiorm/dialect/GenericSQLDialect.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,9 @@ protected String sqlForSelectIdEscaped(String schema, List<String> columns, Stri
(orderBy == null ? "" : ("ORDER BY " + orderBy + "\n"));
}


@Override
public String sqlForCreateSchema(String schema) {
return "CREATE SCHEMA IF NOT EXISTS " + identifier(schema, true);
return "CREATE SCHEMA IF NOT EXISTS " + identifier(schema, false);
}

@Override
Expand Down
18 changes: 17 additions & 1 deletion src/main/java/org/jminiorm/dialect/SybaseASASQLDialect.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,23 @@ protected String sqlForAutoIncrement() {
return "DEFAULT AUTOINCREMENT";
}

@Override
public String sqlForCreateSchema(String schema) {
// SybaseASA does not support the common concept of schema, however a schema is auto-created par user, with an identical name
// the user created is never used for login so the password has not to be known
// as no IF NOT EXISTS is available, it is better not to use it for the moment
// return "CREATE USER " + identifier(schema, false) + " IDENTIFIED BY " + quoteIdentifier(UUID.randomUUID().toString());
return null;
}

@Override
protected String sqlForColumnType(Class<?> javaType, Integer length, Integer scale, Integer precision,
boolean generated) {
if ((javaType == Boolean.class) || (javaType == boolean.class))
return "INTEGER";
else return super.sqlForColumnType(javaType, length, scale, precision, generated);
}

@Override
public String sqlForSelect(String sql, Integer limit, Integer offset) {
String expr = "";
Expand All @@ -22,5 +39,4 @@ public String sqlForSelect(String sql, Integer limit, Integer offset) {
sql = sql.replaceAll("(?i)^select ", "select " + expr);
return sql;
}

}
2 changes: 1 addition & 1 deletion src/main/java/org/jminiorm/query/orm/AbstractORMQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected void verifySchemaExistence() {
String schema = getMapping().getSchema();
if (schema != null && !schema.isEmpty()) {
String sql = getQueryTarget().getConfig().getDialect().sqlForCreateSchema(schema);
getQueryTarget().sql(sql);
if (sql != null) getQueryTarget().sql(sql);
}
}
}
3 changes: 3 additions & 0 deletions src/test/java/org/jminiorm/SchemaBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ public class SchemaBean {
@Column(name = "short_text", length = 16)
private String shortText;
private String longText;
@Column(name = "the_date")
private Date date;
private LocalDate localDate;
private LocalDateTime localDateTime;
private Integer someInt;
// solution for a database without support of BOOLEAN
// @Column(columnDefinition = "INTEGER")
private Boolean someBoolean;
private byte[] bytes;
@Enumerated(EnumType.ORDINAL)
Expand Down
24 changes: 12 additions & 12 deletions src/test/java/org/jminiorm/TestSchemaQueries.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ public void testBatchExecutionMode() throws Exception {
testQueriesOnDatabase(db);
}

// @Test
// public void testPostgreSQL() throws Exception {
// Database db;
// IDatabaseConfig config;
// config = new DatabaseConfig.Builder()
// .dataSource("jdbc:postgresql://localhost/jminiorm", "jminiorm", "jminiorm")
// .statementExecutor(new DefaultStatementExecutor())
// .dialect(new PostgreSQLDialect())
// .build();
// db = new Database(config);
// testQueriesOnDatabase(db);
// }
// @Test
// public void testPostgreSQL() throws Exception {
// Database db;
// IDatabaseConfig config;
// config = new DatabaseConfig.Builder()
// .dataSource("jdbc:postgresql://localhost/jminiorm", "jminiorm", "jminiorm")
// .statementExecutor(new DefaultStatementExecutor())
// .dialect(new PostgreSQLDialect())
// .build();
// db = new Database(config);
// testQueriesOnDatabase(db);
// }

protected void testQueriesOnDatabase(IDatabase db) throws Exception {
// Table creation :
Expand Down

0 comments on commit 9cbbbcd

Please sign in to comment.