, , ( , ...) ('pancakes', 6,...) - SQL, ( , SQL, MySQL, SQL-Server,...). , Ruby , , , Ruby, .
:
where('? > ?', ...)
( ) . ? ActiveRecord , ? (, created_at) (, 20:31:00.00).
, , :
> puts ActiveRecord::Base.connection.quote_column_name('pancakes')
"pancakes"
=> nil
, :
quoted_column = Shift.connection.quote_column_name(column_name)
Shift.where("#{quoted_name}::time > ?", '20:31:00.00')
, (, , ) SQL. , quote_column_name - column_name, .
:
quoted_column = "#{Shift.connection.quote_column_name(column_name)}::time"
Shift.where("#{quoted_name} > ?", '20:31:00.00')
time. :
clause = "#{Shift.connection.quote_column_name(column_name)}::time > ?"
Shift.where(clause, '20:31:00.00')
extract , , quote_column_name.
column_name, . column_name :
if(!in_the_whitelist(column_name))
end
Shift.where("#{column_name} > ?", '20:31:00.00')
, , "gotta have some breakfast" , . Shift.column_names Shift.columns .
, quote_column_name, , , quote_column_name .