use of com.amplifyframework.datastore.storage.sqlite.adapter.SQLPredicate in project amplify-android by aws-amplify.
the class SQLPredicateTest method testContainsForStringField.
/**
* Test contains in the context of a String field.
* @throws DataStoreException Not thrown.
*/
@Test
public void testContainsForStringField() throws DataStoreException {
QueryPredicate predicate = Where.matches(Blog.NAME.contains("something")).getQueryPredicate();
SQLPredicate sqlPredicate = new SQLPredicate(predicate);
validateSQLExpressionForContains(sqlPredicate, "name");
}
use of com.amplifyframework.datastore.storage.sqlite.adapter.SQLPredicate in project amplify-android by aws-amplify.
the class SQLPredicateTest method testNotContainsForStringField.
/**
* Test notContains in the context of a String field.
* @throws DataStoreException Not thrown.
*/
@Test
public void testNotContainsForStringField() throws DataStoreException {
QueryPredicate predicate = Where.matches(Blog.NAME.notContains("something")).getQueryPredicate();
SQLPredicate sqlPredicate = new SQLPredicate(predicate);
validateSQLExpressionForNotContains(sqlPredicate, "name");
}
use of com.amplifyframework.datastore.storage.sqlite.adapter.SQLPredicate in project amplify-android by aws-amplify.
the class SQLPredicateTest method testMatchAllPredicate.
/**
* Test that MATCH ALL predicate is correctly parsed to an
* expression that is always true.
* @throws DataStoreException if parsing fails
*/
@Test
public void testMatchAllPredicate() throws DataStoreException {
QueryPredicate predicate = QueryPredicates.all();
SQLPredicate sqlPredicate = new SQLPredicate(predicate);
assertEquals("1 = 1", sqlPredicate.toString());
assertTrue(sqlPredicate.getBindings().isEmpty());
}
use of com.amplifyframework.datastore.storage.sqlite.adapter.SQLPredicate in project amplify-android by aws-amplify.
the class SQLPredicateTest method testNotContainsForStringList.
/**
* Test notContains in the context of a list.
* @throws DataStoreException Not thrown.
*/
@Test
public void testNotContainsForStringList() throws DataStoreException {
QueryPredicateOperation<String> predicate = Blog.TAGS.notContains("something");
SQLPredicate sqlPredicate = new SQLPredicate(predicate);
validateSQLExpressionForNotContains(sqlPredicate, "tags");
}
use of com.amplifyframework.datastore.storage.sqlite.adapter.SQLPredicate in project amplify-android by aws-amplify.
the class SQLiteCommandFactory method deleteFor.
@NonNull
@Override
public SqlCommand deleteFor(@NonNull ModelSchema modelSchema, @NonNull QueryPredicate predicate) throws DataStoreException {
final SQLiteTable table = SQLiteTable.fromSchema(modelSchema);
final SQLPredicate sqlPredicate = new SQLPredicate(predicate);
final String preparedDeleteStatement = "DELETE FROM" + SqlKeyword.DELIMITER + Wrap.inBackticks(table.getName()) + SqlKeyword.DELIMITER + SqlKeyword.WHERE + SqlKeyword.DELIMITER + sqlPredicate + ";";
return new SqlCommand(table.getName(), preparedDeleteStatement, // WHERE clause
sqlPredicate.getBindings());
}
Aggregations