Skip to content

Commit

Permalink
0001363: SQL Server DateTime2 type does not work with conflict resolu…
Browse files Browse the repository at this point in the history
…tion.
  • Loading branch information
abrougher committed Jul 31, 2013
1 parent abf866e commit 3212c71
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 23 deletions.
Expand Up @@ -479,7 +479,7 @@ protected String cleanTextForTextBasedColumns(String text) {
return text;
}

protected java.util.Date parseDate(int type, String value, boolean useVariableDates) {
public java.util.Date parseDate(int type, String value, boolean useVariableDates) {
if (StringUtils.isNotBlank(value)) {
try {
boolean useTimestamp = (type == Types.TIMESTAMP)
Expand Down
Expand Up @@ -47,7 +47,7 @@ public interface IDatabasePlatform {

/**
* Returns information about this platform.
*
*
* @return The info object
*/
public DatabaseInfo getDatabaseInfo();
Expand All @@ -60,7 +60,7 @@ public interface IDatabasePlatform {
/**
* Returns the ddl reader (which reads a database model from a live
* database) for this platform.
*
*
* @return The model reader
*/
public IDdlReader getDdlReader();
Expand Down Expand Up @@ -96,15 +96,15 @@ public Table getTableFromCache(String catalogName, String schemaName, String tab

public void createDatabase(Database targetDatabase, boolean dropTablesFirst,
boolean continueOnError);

public void createTables(boolean dropTablesFirst,
boolean continueOnError, Table... tables);

public void alterDatabase(Database desiredDatabase, boolean continueOnError);

public void alterTables(boolean continueOnError, Table... desiredTables);

public void dropDatabase(Database database, boolean continueOnError);
public void dropDatabase(Database database, boolean continueOnError);

public DmlStatement createDmlStatement(DmlType dmlType, Table table);

Expand All @@ -116,49 +116,51 @@ public Object[] getObjectValues(BinaryEncoding encoding, String[] values,

public Object[] getObjectValues(BinaryEncoding encoding, Table table, String[] columnNames,
String[] values);

public Object[] getObjectValues(BinaryEncoding encoding, Table table, String[] columnNames,
String[] values, boolean useVariableDates);

public Object[] getObjectValues(BinaryEncoding encoding, String[] values,
Column[] orderedMetaData, boolean useVariableDates);

public String[] getStringValues(BinaryEncoding encoding, Column[] metaData, Row row, boolean useVariableDates);

public Database readDatabaseFromXml(String filePath, boolean alterCaseToMatchDatabaseDefaultCase);

public Database readDatabaseFromXml(InputStream in, boolean alterCaseToMatchDatabaseDefaultCase);

public String alterCaseToMatchDatabaseDefaultCase(String value);

public void alterCaseToMatchDatabaseDefaultCase(Table table);

public void alterCaseToMatchDatabaseDefaultCase(Table... tables);

public void alterCaseToMatchDatabaseDefaultCase(Database database);

public boolean isLob(int type);

public boolean isClob(int type);

public boolean isBlob(int type);

public List<Column> getLobColumns(Table table);

public Map<String, String> getSqlScriptReplacementTokens();

public String scrubSql(String sql);

public boolean isStoresLowerCaseIdentifiers();

public boolean isStoresUpperCaseIdentifiers();

public boolean isStoresMixedCaseQuotedIdentifiers();

public <T> T getDataSource();

public void setMetadataIgnoreCase(boolean value);

public boolean isMetadataIgnoreCase();

public java.util.Date parseDate(int type, String value, boolean useVariableDates);

}
Expand Up @@ -21,6 +21,7 @@
package org.jumpmind.symmetric.io.data.writer;

import java.sql.Timestamp;
import java.sql.Types;
import java.util.Date;
import java.util.Map;
import java.util.TimeZone;
Expand Down Expand Up @@ -244,13 +245,13 @@ protected boolean isTimestampNewer(Conflict conflict, DatabaseWriter writer, Csv
Map<String, String> newData = data.toColumnNameValuePairs(sourceTable.getColumnNames(),
CsvData.ROW_DATA);
String loadingStr = newData.get(columnName);

Date loadingTs = null;
Date existingTs = null;
if (column.getMappedTypeCode() == -101) {
// Get the existingTs with timezone
String existingStr = writer.getTransaction().queryForObject(sql, String.class,
objectValues);
objectValues);
// If you are in this situation because of an instance where the conflict exists
// because the row doesn't exist, then existing simply needs to be null
if (existingStr != null) {
Expand All @@ -273,6 +274,8 @@ protected boolean isTimestampNewer(Conflict conflict, DatabaseWriter writer, Csv
new String[] { loadingStr }, new Column[] { column });
if (values[0] instanceof Date) {
loadingTs = (Date) values[0];
} else if (values[0] instanceof String) {
loadingTs = writer.getPlatform().parseDate(Types.VARCHAR, (String)values[0], false);
} else {
throw new ParseException("Could not parse " + columnName + " with a value of "
+ loadingStr + " for purposes of conflict detection");
Expand Down

0 comments on commit 3212c71

Please sign in to comment.