Added safety check for queries with unknown parameters. The idea came when I used :order instead of :sort and it silently _failed_ to work as expected ;-)

This commit is contained in:
Adrian Madrid 2009-01-06 17:14:45 -07:00
parent e34e404bd9
commit c8072f2f4a
1 changed files with 5 additions and 1 deletions

View File

@ -43,7 +43,11 @@ module XGen
def find(selector={}, options={}) def find(selector={}, options={})
fields = options.delete(:fields) fields = options.delete(:fields)
fields = nil if fields && fields.empty? fields = nil if fields && fields.empty?
@db.query(@name, Query.new(selector, fields, options[:offset] || 0, options[:limit] || 0, options[:sort])) offset = options.delete(:offset) || 0
limit = options.delete(:limit) || 0
sort = options.delete(:sort)
raise RuntimeError, "Unknown options [#{options.inspect}]" unless options.empty?
@db.query(@name, Query.new(selector, fields, offset, limit, sort))
end end
# Insert +objects+, which are hashes. # Insert +objects+, which are hashes.