I'm trying to create a custom association where I have compound primary 
keys, my association looks like this



    one_to_many :desired_values,
                :key         => [:check_id, :computer_id],
                :primary_key => [:check_id, :computer_id],
                :order       => [:human_name, :name],
                :reportable  => true,
                :class_name  => "SCM::ReportDesiredValue",
                :dataset => proc {|r|
                  r.associated_dataset.join(:scm__check_results, :check_id 
=> :check_id) do |j, lj, js|
                    Sequel.|(:computer_id.qualify(j) => 
:computer_id.qualify(lj), :computer_id.qualify(lj) => nil)
                  
end.order(:computer_id.qualify(:scm__report_desired_values).desc)
                }

The difference is in 'OR' and 'AND' for the last condition 

 and I would expect to get following SQL out of it : 
"SELECT * FROM [scm].[report_desired_values] AS [report_desired_values] 
INNER JOIN [scm].[check_results] ON (([scm].[check_results].[check_id] = 
[report_desired_values].[check_id]) AND 
((([scm].[check_results].[computer_id] = 
[report_desired_values].[computer_id]) OR 
([report_desired_values].[computer_id] IS NULL)))) ORDER BY 
[scm].[report_desired_values].[computer_id] DESC

But instead sequel generates: 

"SELECT * FROM [scm].[report_desired_values] AS [report_desired_values] 
INNER JOIN [scm].[check_results] ON (([scm].[check_results].[check_id] = 
[report_desired_values].[check_id]) AND 
((([scm].[check_results].[computer_id] = 
[report_desired_values].[computer_id]) AND 
([report_desired_values].[computer_id] IS NULL)))) ORDER BY 
[scm].[report_desired_values].[computer_id] DESC

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to