Skip to content

Commit

Permalink
instead of string concatenation move single quotes to format string
Browse files Browse the repository at this point in the history
as the formatter is only used for formatting we are safe to include the single quotes
  • Loading branch information
darkv committed Nov 15, 2012
1 parent 889e454 commit 6eb39a6
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class PostgresqlExpression extends JDBCExpression {
private static final ThreadLocal<SimpleDateFormat> DATE_FORMATTER = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy-MM-dd");
return new SimpleDateFormat("''yyyy-MM-dd''");
}
};

Expand All @@ -85,7 +85,7 @@ protected SimpleDateFormat initialValue() {
private static final ThreadLocal<SimpleDateFormat> TIMESTAMP_FORMATTER = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
return new SimpleDateFormat("''yyyy-MM-dd HH:mm:ss.SSS''");
}
};

Expand Down Expand Up @@ -444,9 +444,9 @@ public String formatValueForAttribute(Object obj, EOAttribute eoattribute) {
if(obj instanceof NSData) {
value = sqlStringForData((NSData)obj);
} else if((obj instanceof NSTimestamp) && isTimestampAttribute(eoattribute)) {
value = "'" + TIMESTAMP_FORMATTER.get().format(obj) + "'";
value = TIMESTAMP_FORMATTER.get().format(obj);
} else if((obj instanceof NSTimestamp) && isDateAttribute(eoattribute)) {
value = "'" + DATE_FORMATTER.get().format(obj) + "'";
value = DATE_FORMATTER.get().format(obj);
} else if(obj instanceof String) {
value = formatStringValue((String)obj);
} else if(obj instanceof Number) {
Expand Down

0 comments on commit 6eb39a6

Please sign in to comment.