Created
July 14, 2017 06:20
-
-
Save midhunkrishna/2adc07cd77002b5d49358ef69237b805 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from_cte_sql = ::Namespace::From.where_clause | |
# .. | |
from_table = Arel::Table.new(:from_lane) | |
to_table = Arel::Table.new(:to_lane) | |
rates_table = Arel::Table.new(:rates) | |
rates_table | |
.join(from_table).on(rates_table[:from_id].eq(from_table[:id])) | |
.join(to_table).on(rates_table[:to_id].eq(to_table[:id])) | |
.project(rates_table[Arel.star]) | |
.with([ | |
Arel::Nodes::As.new(from_table, | |
Arel::Nodes::SqlLiteral.new("(#{from_cte_sql.to_sql})")), | |
Arel::Nodes::As.new(to_table, | |
Arel::Nodes::SqlLiteral.new("(#{to_cte_sql.to_sql})")), | |
Arel::Nodes::As.new(rates_table, | |
Arel::Nodes::SqlLiteral.new("(#{rate_cte_sql.to_sql})"))]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment