Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add required argument dataset to sql_literal. Add alias sql_literal f…

…or to_s.
  • Loading branch information...
commit 5c2fa386c325de5d91afb694ee91309369989067 1 parent 2218e51
@michaeldiamond michaeldiamond authored committed
Showing with 10 additions and 2 deletions.
  1. +5 −2 lib/sequel/dataset/sql.rb
  2. +5 −0 lib/sequel/sql.rb
View
7 lib/sequel/dataset/sql.rb
@@ -810,12 +810,15 @@ def literal_integer(v)
v.to_s
end
- # SQL fragmento for a type of object not handled by Dataset#literal.
+ # SQL fragment for a type of object not handled by Dataset#literal.
# Calls sql_literal if object responds to it, otherwise raises an error.
+ # Classes implementing sql_literal should call a class-specific method on the dataset
+ # provided and should add that method to Sequel::Dataset, allowing for adapters
+ # to provide customized literalizations.
# If a database specific type is allowed, this should be overriden in a subclass.
def literal_other(v)
if v.respond_to?(:sql_literal)
- v.sql_literal
+ v.sql_literal(self)
else
raise Error, "can't express #{v.inspect} as a SQL literal"
end
View
5 lib/sequel/sql.rb
@@ -49,6 +49,11 @@ def self.to_s_method(meth, args=:self) # :nodoc:
def lit
self
end
+
+ # Alias for to_s
+ def sql_literal(ds)
+ to_s(ds)
+ end
end
# Represents a complex SQL expression, with a given operator and one
Please sign in to comment.
Something went wrong with that request. Please try again.