在該示例中SqlDelight documentation,從HockeyPlayer.sq
文件由SqlDelight產生的HockeyPlayerModel
在一個抽象類public abstract class HockeyPlayer implements HockeyPlayerModel
SqlDelight不產生SQL查詢字符串SQL語句
被實現在這個類中,字符串SELECT_ALL_INFO
在作爲傳遞查詢到db.rawQuery(SELECT_ALL_INFO, new String[0])
。字符串SELECT_ALL_INFO
由HockeyPlayer.sq
內的select_all_info
聲明生成。但是,在我的情況下,我的表述不會產生字符串。爲什麼是這樣?
我的發言
names_for_groups:
SELECT DISTINCT name, exercise_set_group FROM exercise_set JOIN exercises
USING (exercise_id) WHERE workout_FK = ? ORDER BY exercise_set_group ASC ;
通過SqlDelight
@AutoValue
public abstract class DbExerciseSet implements ExerciseSetModel, DbItem {
public static final Factory<DbExerciseSet> FACTORY = new Factory<>(AutoValue_DbExerciseSet::new);
public static final RowMapper<DbExerciseSet> MAPPER = FACTORY.select_allMapper();
public static final RowMapper<NamesForGroups> NAMES_FOR_GROUPS_MAPPER =
FACTORY.names_for_groupsMapper(AutoValue_DbExerciseSet_NamesForGroups::new);
public List<NamesForGroups> namesForGroups(SQLiteDatabase db) {
List<NamesForGroups> namesForGroupsList= new ArrayList<>();
Cursor cursor = db.rawQuery(NAMES_FOR_GROUPS, new String[0]);
while (cursor.moveToNext() && NAMES_FOR_GROUPS_MAPPER.map(cursor) != null) {
//NamesForGroups namesForGroups = NAMES_FOR_GROUPS_MAPPER.map(cursor);
namesForGroupsList.add(NAMES_FOR_GROUPS_MAPPER.map(cursor));
}
return namesForGroupsList;
}
@AutoValue
public abstract static class NamesForGroups implements Names_for_groupsModel {}
@AutoValue
public abstract static class Exercises implements ExerciseModel {}
}
需要明確的是,該變量引用NAMES_FOR_GROUPS沒有在該行發現db.rawQuery(NAMES_FOR_GROUPS, new String[0])
滿拉請求:https://github.com/square/sqldelight/pull/628 – Anstrong
非常感謝;我在這段時間裏一直在絞盡腦汁 –