ためのSQLクエリ文字列を生成しないSqlDelight、HockeyPlayer.sq
ファイルからSqlDelightによって生成HockeyPlayerModel
このクラスでは抽象クラスpublic abstract class HockeyPlayer implements HockeyPlayerModel
は<a href="https://github.com/square/sqldelight#join-projections" rel="nofollow noreferrer">SqlDelight documentation</a>の例ではSQLステートメント
に実装され、文字列SELECT_ALL_INFO
はとして渡されますdb.rawQuery(SELECT_ALL_INFO, new String[0])
へのクエリ。文字列SELECT_ALL_INFO
は、select_all_info
ステートメントHockeyPlayer.sq
の内部で生成されました。しかし、私の状況では、私のステートメントは文字列を生成していません。どうしてこれなの?
マイ声明
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 {}
}
によって生成されるExerciseSetModel
の私の実装、可変基準NAMES_FOR_GROUPSが一列に見つからないdb.rawQuery(NAMES_FOR_GROUPS, new String[0])
ドキュメントの変更を完全にプル要求:https://github.com/squareは/ sqldelight/pull/628 – Anstrong
非常に高く評価されています。私はこの間に私の脳をかなり壊していた –