JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources
Filtering with .where method: no matches without ActiveRecord
まだ誰も着手していません。
- 主要言語
- Ruby
- スター
- 2.3k
- フォーク
- 546
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
I am really excited about the progress of JSON API spec and the JSON API Resources Gem.
In my experiments with the gem, I found the following to be incompatible with Mongoid, the ActiveRecord replacement for integrating with MongoDB.
def apply_filter(records, filter, value)
records.where(filter => value)
end
The value passed to this method is always an array. In ActiveRecord, passing an array value to the where method builds an IN SQL query. The challenge with something like Mongoid is that values can be stored as arrays. Thus, Contact.where(:github => ['realityendshere']) seems to search for contact records where the github property is exactly equal to the array ['realityendshere'] and does not return the expected results.
It's easy to override this method in my app's resources:
def self.apply_filter(records, filter, value)
records.in(filter => value)
end
Hopefully, this helps anyone else trying to understand how jsonapi-resources gem works with ActiveRecord alternatives.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
報告されたエントリポイントは apply_filter(records, filter, value) で、現在は records.where(filter => value) を呼び出しています。まずそこから始め、issue に記載されている ActiveRecord と Mongoid の動作を比較してください。意図されたアダプター非依存の動作を確認し、既存の ActiveRecord のマッチングを維持したまま、値が配列であるフィルターのカバレッジを追加してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- mongodb, rails, ruby
- 領域
- api, backend, database
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 30/100