Skip to content

Commit

Permalink
0003212: Add NuoDB Dialect
Browse files Browse the repository at this point in the history
  • Loading branch information
klementinastojanovska committed Aug 3, 2017
1 parent f1ec560 commit daf2e3d
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 13 deletions.
Expand Up @@ -31,7 +31,7 @@ public class NuoDbTriggerTemplate extends AbstractTriggerTemplate {
public NuoDbTriggerTemplate(ISymmetricDialect symmetricDialect) {
super(symmetricDialect);
emptyColumnTemplate = "''" ;
stringColumnTemplate = "cast(case when $(tableAlias).`$(columnName)` is null then '' else concat('\"',replace(replace($(tableAlias).`$(columnName)`,'\\\\','\\\\\\\\'),'\"','\\\\\"'),'\"') end as char)\n" ;
stringColumnTemplate = "cast(case when $(tableAlias).`$(columnName)` is null then '' else concat('\"',replace(replace($(tableAlias).`$(columnName)`,'\\\\','\\\\\\\\'),'\"','\\\"'),'\"') end as char)\n" ;
numberColumnTemplate = "case when $(tableAlias).\"$(columnName)\" is null then '' else concat('\"',cast($(tableAlias).\"$(columnName)\" as char),'\"') end \n" ;
datetimeColumnTemplate = "case when $(tableAlias).\"$(columnName)\" is null then '' else concat('\"',cast($(tableAlias).\"$(columnName)\" as char),'\"') end\n" ;
clobColumnTemplate = stringColumnTemplate;
Expand Down
Expand Up @@ -515,7 +515,7 @@ public void testExportCsvToDirectory() throws Exception {
Assert.assertTrue(a.isFile());
List<String> lines = FileUtils.readLines(a);
Assert.assertEquals(9, lines.size());
Assert.assertEquals("\"id\",\"string_value\"", lines.get(5));
Assert.assertTrue("\"id\",\"string_value\"".equalsIgnoreCase(lines.get(5)));
Assert.assertEquals("\"1\",\"This is a test of a\"", lines.get(6));
Assert.assertEquals("\"2\",\"This is a test of a\"", lines.get(7));

Expand All @@ -524,7 +524,7 @@ public void testExportCsvToDirectory() throws Exception {
Assert.assertTrue(b.isFile());
lines = FileUtils.readLines(b);
Assert.assertEquals(10, lines.size());
Assert.assertEquals("\"id\",\"string_value\"", lines.get(5));
Assert.assertTrue("\"id\",\"string_value\"".equalsIgnoreCase(lines.get(5)));
Assert.assertEquals("\"1\",\"This is a test of b\"", lines.get(6));
Assert.assertEquals("\"2\",\"This is a test of b\"", lines.get(7));
Assert.assertEquals("\"3\",\"This is line 3 of b\"", lines.get(8));
Expand All @@ -534,7 +534,7 @@ public void testExportCsvToDirectory() throws Exception {
Assert.assertTrue(c.isFile());
lines = FileUtils.readLines(c);
Assert.assertEquals(9, lines.size());
Assert.assertEquals("\"id\",\"string_value\"", lines.get(5));
Assert.assertTrue("\"id\",\"string_value\"".equalsIgnoreCase(lines.get(5)));
Assert.assertEquals("\"1\",\"This is a test of c\"", lines.get(6));
Assert.assertEquals("\"2\",\"This is a test of c\"", lines.get(7));

Expand Down Expand Up @@ -580,5 +580,8 @@ protected Row findInList(List<Row> rows, String pk, Object pkValue) {
}
return null;
}




}
Expand Up @@ -101,7 +101,7 @@ public void saveParameter(String externalId, String nodeGroupId, String key, Obj
int count = sqlTemplate.update(sql.getSql("updateParameterSql"), new Object[] { paramValue, lastUpdateBy,
externalId, nodeGroupId, key });

if (count == 0) {
if (count <= 0) {
sqlTemplate.update(sql.getSql("insertParameterSql"), new Object[] { externalId,
nodeGroupId, key, paramValue, lastUpdateBy });
}
Expand Down
Expand Up @@ -131,7 +131,7 @@ protected void save(TestExtract obj) {
.format("insert into %s (varchar_value, longvarchar_value, timestamp_value, date_value, bit_value, bigint_value, decimal_value, id) values(?,?,?,?,?,?,?,?)",
TEST_TABLE);

if (0 == getSqlTemplate().update(
if (0 >= getSqlTemplate().update(
updateSql,
new Object[] { obj.getVarcharValue(), obj.getLongVarcharValue(),
obj.getTimestampValue(), obj.getDateValue(), obj.isBitValue(),
Expand Down
Expand Up @@ -57,7 +57,7 @@ public NuoDbDdlBuilder() {
databaseInfo.setCommentPrefix("//");
databaseInfo.setDelimiterToken("`");

databaseInfo.addNativeTypeMapping(Types.BIT, "BOOLEAN");
databaseInfo.addNativeTypeMapping(Types.BIT, "BOOLEAN", Types.BOOLEAN);
databaseInfo.addNativeTypeMapping(Types.BLOB, "BLOB");
databaseInfo.addNativeTypeMapping(Types.CLOB, "TEXT");
databaseInfo.addNativeTypeMapping(Types.FLOAT, "DOUBLE");
Expand All @@ -73,7 +73,7 @@ public NuoDbDdlBuilder() {
databaseInfo.addNativeTypeMapping(Types.SMALLINT, "SMALLINT");
databaseInfo.addNativeTypeMapping(Types.INTEGER, "INTEGER");
databaseInfo.addNativeTypeMapping(Types.BIGINT, "BIGINT");
databaseInfo.addNativeTypeMapping(Types.BOOLEAN, "BOOLEAN");
databaseInfo.addNativeTypeMapping(Types.BOOLEAN, "BOOLEAN",Types.BOOLEAN);
databaseInfo.addNativeTypeMapping(Types.DECIMAL, "DECIMAL");
databaseInfo.addNativeTypeMapping(Types.DATE, "DATE");
databaseInfo.addNativeTypeMapping(Types.TIME, "TIME");
Expand All @@ -86,7 +86,7 @@ public NuoDbDdlBuilder() {

databaseInfo.setNonBlankCharColumnSpacePadded(false);
databaseInfo.setBlankCharColumnSpacePadded(false);
databaseInfo.setCharColumnSpaceTrimmed(true);
databaseInfo.setCharColumnSpaceTrimmed(false);
databaseInfo.setEmptyStringNulled(false);

databaseInfo.setSyntheticDefaultValueForRequiredReturned(false);
Expand Down
Expand Up @@ -244,7 +244,7 @@ protected Integer mapUnknownJdbcTypeForColumn(Map<String, Object> values) {
if (type != null && type.intValue() == Types.CLOB) {
// XML longvarchar becoms longvarchar on Column but becomes clob in database
return Types.LONGVARCHAR;
} else {
}else {
return super.mapUnknownJdbcTypeForColumn(values);
}
}
Expand Down
Expand Up @@ -20,6 +20,8 @@
*/
package org.jumpmind.db.platform.nuodb;

import java.sql.Types;

import javax.sql.DataSource;

import org.jumpmind.db.platform.DatabaseInfo;
Expand All @@ -39,5 +41,14 @@ public NuoDbJdbcSqlTemplate(DataSource dataSource, SqlTemplateSettings settings,
public String getSelectLastInsertIdSql(String sequenceName) {
return "select last_insert_id() from dual";
}

@Override
protected int verifyArgType(Object arg, int argType) {
if (argType == Types.BIT){
return Types.BOOLEAN;
} else {
return super.verifyArgType(arg, argType);
}
}

}
Expand Up @@ -341,7 +341,7 @@ public ISqlTransaction startSqlTransaction() {
public int update(final String sql, final Object[] args, final int[] types) {
return execute(new IConnectionCallback<Integer>() {
public Integer execute(Connection con) throws SQLException {
if (args == null) {
if (args == null) {
Statement stmt = null;
try {
stmt = con.createStatement();
Expand Down
Expand Up @@ -67,7 +67,7 @@ protected void test(ISymmetricEngine rootServer, ISymmetricEngine clientServer)
}

loadConfigAtRegistrationServer();

assertEquals(0, clientServer.getSqlTemplate().queryForInt("select count(*) from a"));
assertEquals(0, clientServer.getSqlTemplate().queryForInt("select count(*) from b"));
assertEquals(0, clientServer.getSqlTemplate().queryForInt("select count(*) from c"));
Expand All @@ -80,7 +80,7 @@ protected void test(ISymmetricEngine rootServer, ISymmetricEngine clientServer)
assertNotNull(clientNode);

rootServer.getDataService().reloadNode(clientNode.getNodeId(), false, "unit test");

pull("client");

// load succeeded
Expand Down

0 comments on commit daf2e3d

Please sign in to comment.