Skip to content

InMemoryCommentRepository.find_all_by_note() がソートされない #128

@hideyukiMORI

Description

@hideyukiMORI

問題

src/example/comment/repository.pyInMemoryCommentRepository.find_all_by_note() にソートがなく、SqlAlchemyCommentRepositoryORDER BY id と挙動が異なる。

# InMemory — ソートなし
items = [c for c in self._store.values() if c.note_id == note_id]
return items[offset : offset + limit]

# SQLAlchemy — ORDER BY id あり
"SELECT ... WHERE note_id = :note_id ORDER BY id LIMIT :limit OFFSET :offset"

削除・再挿入後のページネーション順序が不定になりテスト不一致を引き起こす。

修正方針

sorted(items, key=lambda c: c.id) を追加する。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions