lib/torque/postgresql/auxiliary_statement/settings.rb in torque-postgresql-0.1.2 vs lib/torque/postgresql/auxiliary_statement/settings.rb in torque-postgresql-0.1.3

- old
+ new

@@ -19,12 +19,24 @@ raise StandardError, 'The query is not defined yet' if query.nil? return query.arel_table if relation_query?(query) @query_table end + # Grant an easy access to arel table columns + def col(name) + query_table[name.to_s] + end + + alias column col + + # Grant an easy access to arel sql literal + def sql(string) + ::Arel::Nodes::SqlLiteral.new(string) + end + # There are two ways of setting the query: - # - A simple relation based on a modle + # - A simple relation based on a Model # - A string or a proc that requires the table name as first argument def query(value = nil, command = nil) return @query if value.nil? return @query = value if relation_query?(value) @@ -37,10 +49,10 @@ Only relation, string and proc are valid object types for query, #{command.inspect} given. MSG @query = command - @query_table = Arel::Table.new(value) + @query_table = ::Arel::Table.new(value) end end end end