use of com.activeandroid.query.From in project ActiveAndroid by pardom.
the class FromTest method testWhereAndChaining.
public void testWhereAndChaining() {
From expected = from().where("a = ? AND b = ?", 1, 2);
From actual = from().where("a = ?", 1).and("b = ?", 2);
assertSqlEquals(expected, actual);
}
use of com.activeandroid.query.From in project ActiveAndroid by pardom.
the class FromTest method testWhereAlternateAndOrChaining.
public void testWhereAlternateAndOrChaining() {
From expected = from().where("a = ? OR (b = ? AND c = ?)", 1, 2, 3);
From actual = from().where("a = ?", 1).or("(b = ?", 2).and("c = ?)", 3);
assertSqlEquals(expected, actual);
}
use of com.activeandroid.query.From in project ActiveAndroid by pardom.
the class FromTest method testWhereAndOrChaining.
public void testWhereAndOrChaining() {
From expected = from().where("a = ? OR (b = ? AND c = ?)", 1, 2, 3);
From actual = from().where("a = ?", 1).or("(b = ? AND c = ?)", 2, 3);
assertSqlEquals(expected, actual);
}
use of com.activeandroid.query.From in project ActiveAndroid by pardom.
the class FromTest method testWhereWithNoArgumentsAndWithArguments.
// Test with 'no arguments' and 'with arguments' chained together.
public void testWhereWithNoArgumentsAndWithArguments() {
From query = from().where("Id = 5");
query.where("Id > ?", 4);
assertArrayEquals(query.getArguments(), "4");
assertSqlEquals(SELECT_PREFIX + "WHERE Id = 5 AND Id > ?", query);
}
use of com.activeandroid.query.From in project ActiveAndroid by pardom.
the class FromTest method testWhereWithArguments.
public void testWhereWithArguments() {
From query = from().where("Id = ?", 5);
assertArrayEquals(query.getArguments(), "5");
assertSqlEquals(SELECT_PREFIX + "WHERE Id = ?", query);
query = from().where("Id > ? AND Id < ?", 5, 10);
assertArrayEquals(query.getArguments(), "5", "10");
assertSqlEquals(SELECT_PREFIX + "WHERE Id > ? AND Id < ?", query);
// Chained
query = from().where("Id != ?", 10).where("Id IN (?, ?, ?)", 5, 10, 15).where("Id > ? AND Id < ?", 5, 10);
assertArrayEquals(query.getArguments(), "10", "5", "10", "15", "5", "10");
assertSqlEquals(SELECT_PREFIX + "WHERE Id != ? AND Id IN (?, ?, ?) AND Id > ? AND Id < ?", query);
}