Module: SQLRecord::SanitizedQuery
- Included in:
- Base
- Defined in:
- lib/sql_record/sanitized_query.rb
Instance Method Summary collapse
-
#find(params = {}) ⇒ Array
Executes the #query proc on your database, building SQLRecords with the results.
-
#query {|params| ... } ⇒ Object
Specifies the query to execute.
Instance Method Details
#find(params = {}) ⇒ Array
Executes the #query proc on your database, building SQLRecords with the results.
6 7 8 9 10 11 12 |
# File 'lib/sql_record/sanitized_query.rb', line 6 def find params={} rows = execute_query params rows.map do |row| new row end end |
#query {|params| ... } ⇒ Object
Note:
do not try to sanitize identifiers, only values will sanitize well
["where id = ?", 1] => "where id = 1"
["where name = ?", "hello"] => "where id = 'hello'"
["ORDER BY ? ASC", "id"] => "ORDER BY 'id' ASC" << not legitimate SQL
Specifies the query to execute
23 24 25 |
# File 'lib/sql_record/sanitized_query.rb', line 23 def query &deferred @query_proc = deferred end |