Skip to content

Commit

Permalink
Bugfixes for PostgreSQL
Browse files Browse the repository at this point in the history
  • Loading branch information
schuemie committed Jul 15, 2017
1 parent 9bbd9e5 commit 585c3c6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/org/ohdsi/databases/ConnectionWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ public void insertIntoTable(String tableName, List<Row> rows, boolean emptyStrin
System.out.println(row.toString());
if (value.length() == 0 && emptyStringToNull)
value = null;
if (dbType == DbType.POSTGRESQL) // PostgreSQL does not allow unspecified types
if (dbType.equals(DbType.POSTGRESQL)) // PostgreSQL does not allow unspecified types
statement.setObject(i + 1, value, Types.OTHER);
else if (dbType == DbType.ORACLE) {
else if (dbType.equals(DbType.ORACLE)) {
statement.setString(i + 1, value);
} else
statement.setString(i + 1, value);
Expand All @@ -196,11 +196,16 @@ else if (dbType == DbType.ORACLE) {
public void createTable(String table, List<String> fields, List<String> types, List<String> primaryKey) {
StringBuilder sql = new StringBuilder();
sql.append("CREATE TABLE " + table + " (\n");
boolean first = true;
for (int i = 0; i < fields.size(); i++) {
sql.append(" " + fields.get(i) + " " + types.get(i) + ",\n");
if (first)
first = false;
else
sql.append(",\n");
sql.append(" " + fields.get(i) + " " + types.get(i));
}
if (primaryKey != null && primaryKey.size() != 0)
sql.append(" PRIMARY KEY (" + StringUtilities.join(primaryKey, ",") + ")\n");
sql.append("\n PRIMARY KEY (" + StringUtilities.join(primaryKey, ",") + ")\n");
sql.append(");\n\n");
execute(Abbreviator.abbreviate(sql.toString()));
}
Expand Down

0 comments on commit 585c3c6

Please sign in to comment.