Skip to content

Commit

Permalink
#491 Incorrect conversion of TIME to java.sql.Time in JTDS driver
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Polevoy committed Apr 24, 2016
1 parent 1933b45 commit 13e9662
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions activejdbc/src/test/java/org/javalite/activejdbc/ModelTest.java
Expand Up @@ -31,6 +31,7 @@
import java.util.NoSuchElementException;
import java.util.Set;

import static org.javalite.activejdbc.test.JdbcProperties.driver;
import static org.javalite.common.Collections.*;


Expand Down Expand Up @@ -517,7 +518,12 @@ public void shouldGenerateValidUpdateSQLWithTime() {
the(Base.exec(updateSql)).shouldBeEqual(1);

alarm = Alarm.findById(alarm.getId());
the(alarm.getString("alarm_time").startsWith(t)).shouldBeTrue();

if(driver().contains("jtds")){
the(alarm.getString("alarm_time").startsWith(t)).shouldBeTrue();
}else {
the(alarm.getTime("alarm_time").toString()).shouldBeEqual(t);
}
}

@Test(expected = NoSuchElementException.class)
Expand Down Expand Up @@ -556,7 +562,12 @@ public void shouldGenerateValidInsertSQLWithTime() {
Object id = Base.execInsert(insertSql, alarm.getIdName());

alarm = Alarm.findById(id);
the(alarm.getTime("alarm_time").toString()).shouldBeEqual(t);

if(driver().contains("jtds")){
the(alarm.getString("alarm_time").startsWith(t)).shouldBeTrue();
}else {
the(alarm.getTime("alarm_time").toString()).shouldBeEqual(t);
}
}

@Test
Expand Down Expand Up @@ -696,7 +707,7 @@ public void testNewFromMap() {
}

@Test
public void testNewFromMapCaseInsensive() {
public void testNewFromMapCaseInsensitive() {
Person p = new Person().fromMap(map("NAME", "Joe", "Last_Name", "Schmoe", "dob", "2003-06-15"));

a(p.get("name")).shouldNotBeNull();
Expand All @@ -712,6 +723,11 @@ public void shouldConvertTime() {
alarm.save();

alarm = Alarm.findById(alarm.getId());
the(alarm.getTime("alarm_time").toString()).shouldBeEqual(t);

if(driver().contains("jtds")){
the(alarm.getString("alarm_time").startsWith(t)).shouldBeTrue();
}else {
the(alarm.getTime("alarm_time").toString()).shouldBeEqual(t);
}
}
}

0 comments on commit 13e9662

Please sign in to comment.