在该示例中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
非常感谢;我在这段时间里一直在绞尽脑汁 –