Skip to content

Commit 1a89bd2

Browse files
chore(datastore) minor simplification in SQLiteStorageAdapter (#1120)
1 parent 8e2a23e commit 1a89bd2

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

aws-datastore/src/main/java/com/amplifyframework/datastore/storage/sqlite/SQLiteStorageAdapter.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -852,17 +852,11 @@ private boolean modelExists(Model model, QueryPredicate predicate) throws DataSt
852852
* @return the Model instance from SQLite, if it exists, otherwise null.
853853
*/
854854
private Model query(Model model) {
855-
final String modelName = getModelName(model);
856-
final ModelSchema schema = modelSchemaRegistry.getModelSchemaForModelClass(modelName);
857-
final SQLiteTable table = SQLiteTable.fromSchema(schema);
858-
final String primaryKeyName = table.getPrimaryKeyColumnName();
859-
final QueryPredicate matchId = QueryField.field(primaryKeyName).eq(model.getId());
860-
861855
Iterator<? extends Model> result = Single.<Iterator<? extends Model>>create(emitter -> {
862856
if (model instanceof SerializedModel) {
863-
query(modelName, Where.matches(matchId), emitter::onSuccess, emitter::onError);
857+
query(getModelName(model), Where.id(model.getId()), emitter::onSuccess, emitter::onError);
864858
} else {
865-
query(model.getClass(), Where.matches(matchId), emitter::onSuccess, emitter::onError);
859+
query(model.getClass(), Where.id(model.getId()), emitter::onSuccess, emitter::onError);
866860
}
867861
}).blockingGet();
868862
return result.hasNext() ? result.next() : null;

0 commit comments

Comments
 (0)