module Sequel::QueryLiterals
The QueryLiterals module can be used to make select, group, and order methods operate similar to the filter methods if the first argument is a plain string, treating it like a literal string, with any remaining arguments treated as placeholder values.
This adds such support to the following methods: select, select_append, select_group, select_more, group, group_and_count, order, order_append, and order_more.
Note that if you pass a block to these methods, it will use the default implementation without the special literal handling.
Private Instance Methods
query_literal(args)
click to toggle source
If the first argument is a plain string, return a literal string if there are no additional args or a placeholder literal string with the remaining args. Otherwise, return nil.
# File lib/sequel/extensions/query_literals.rb, line 65 def query_literal(args) case (s = args[0]) when LiteralString, SQL::Blob nil when String if args.length == 1 LiteralString.new(s) else SQL::PlaceholderLiteralString.new(s, args[1..-1]) end end end