Reputation: 26718
I'm trying to construct a query that needs to adjust a number by a percentage, like 80% would be * 0.80.
I can multiply by an integer:
Arel::Nodes::Multiplication.new(Inventory.arel_table[:available].sum, 3).to_sql
=> "SUM(\"inventories\".\"available\") * 3"
I get an error when I try to multiply by a float.
Arel::Nodes::Multiplication.new(Inventory.arel_table[:available].sum, 3.1).to_sql
RuntimeError: unsupported: Float
What am I missing here?
Upvotes: 4
Views: 997
Reputation: 12402
Arel::Nodes::Multiplication.new(
Inventory.arel_table[:available].sum,
Arel::Nodes::SqlLiteral.new('0.80')
).to_sql
Upvotes: 1