私は次のクエリを作成しています
PortfolioDistribution.joins(:portfolio_distribution_split).
select('policy_number, reinvestment_date, reinvestment_units,
reinvestment_units, split_name, split_percentage').
where(:policy_number => policy_no, :reinvestment_date => period,
:ods_psgamas_gls_portfolio_distribution_split => { :split_name => type })
これは 15 レコードを返しますが、関連付けられたモデルportfolio_distribution_split
はnil
. 次のように Associaterd モデルを含めるようにクエリを変更すると、次のようになります。
PortfolioDistribution.joins(:portfolio_distribution_split).
select('policy_number, reinvestment_date, reinvestment_units,
reinvestment_units, split_name, split_percentage').
where(:policy_number => policy_no, :reinvestment_date => period,
:ods_psgamas_gls_portfolio_distribution_split => { :split_name => type }).
includes(:portfolio_distribution_split)
レコードは 3 つしか取得できませんか? 生成さSQL
れたものをデータベースに対して直接実行すると、15 レコードが得られます。残りの 12 レコードはどうなりましたか?
- アクティブモデル (3.2.13)
- アクティブレコード (3.2.13)
- activerecord-sqlserver-adapter (3.2.8)
- アクティブリソース (3.2.13)
- アクティブサポート (3.2.13)