mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#817 - SqlRow getBoolean() does not treat numeric 1 value as true (with MySql and other DB's without native boolean type)
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package com.avaje.ebean;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class SqlRowBooleanTest {
|
||||
|
||||
@Test
|
||||
public void getBoolean() {
|
||||
|
||||
SqlQuery sqlQuery = Ebean.createSqlQuery("SELECT 1 IS NOT NULL AS `ISNT_NULL`");
|
||||
SqlRow row = sqlQuery.findUnique();
|
||||
|
||||
Boolean value = row.getBoolean("ISNT_NULL");
|
||||
|
||||
assertThat(value).isTrue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.avaje.ebeaninternal.server.core;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class BasicTypeConverterTest {
|
||||
|
||||
@Test
|
||||
public void toBoolean_when_1_long() throws Exception {
|
||||
assertTrue(BasicTypeConverter.toBoolean(1L, "T"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toBoolean_when_1_int() throws Exception {
|
||||
assertTrue(BasicTypeConverter.toBoolean(1, "T"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toBoolean_when_0() throws Exception {
|
||||
assertFalse(BasicTypeConverter.toBoolean(0L, "T"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toBoolean_when_TrueValue() throws Exception {
|
||||
assertTrue(BasicTypeConverter.toBoolean("T", "T"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toBoolean_when_notTrueValue() throws Exception {
|
||||
assertFalse(BasicTypeConverter.toBoolean("F", "T"));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user