Skip to content

Commit 2824d67

Browse files
author
Igor Polevoy
authored
Merge pull request #736 from jfcabral/bugfix/638
[Test@SQLite] - Update SQLiteDialect overrideDriverTypeConversion to support empty date
2 parents 90fae00 + 878a44e commit 2824d67

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

activejdbc/src/main/java/org/javalite/activejdbc/dialects/MSSQLDialect.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.util.regex.Pattern;
77
import org.javalite.activejdbc.DBException;
88
import org.javalite.activejdbc.MetaModel;
9+
import org.javalite.common.Util;
910

1011
import static org.javalite.common.Util.join;
1112

@@ -100,7 +101,7 @@ private String getAllColumns(String[] columns){
100101
*/
101102
@Override
102103
public Object overrideDriverTypeConversion(MetaModel mm, String attributeName, Object value) {
103-
if (value instanceof String && !((String) value).isEmpty()) {
104+
if (value instanceof String && !Util.blank(value)) {
104105
String typeName = mm.getColumnMetadata().get(attributeName).getTypeName();
105106
if ("date".equalsIgnoreCase(typeName)) {
106107
return java.sql.Date.valueOf((String) value);

activejdbc/src/main/java/org/javalite/activejdbc/dialects/SQLiteDialect.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.util.List;
1919
import org.javalite.activejdbc.MetaModel;
2020
import org.javalite.common.Convert;
21+
import org.javalite.common.Util;
2122

2223
/**
2324
* @author Igor Polevoy
@@ -35,7 +36,7 @@ public String formSelect(String tableName, String[] columns, String subQuery, Li
3536
@Override
3637
public Object overrideDriverTypeConversion(MetaModel mm, String attributeName, Object value) {
3738
// SQLite returns DATE and DATETIME as String or Number values
38-
if (value instanceof String || value instanceof Number) {
39+
if (value instanceof String && !Util.blank(value) || value instanceof Number) {
3940
String typeName = mm.getColumnMetadata().get(attributeName).getTypeName();
4041
if ("DATE".equalsIgnoreCase(typeName)) {
4142
return Convert.toSqlDate(value);

0 commit comments

Comments
 (0)