lib/veritas/sql/generator.rb in veritas-sql-generator-0.0.3 vs lib/veritas/sql/generator.rb in veritas-sql-generator-0.0.4

- old
+ new

@@ -3,20 +3,28 @@ require 'date' require 'time' require 'veritas' -require 'veritas/base_relation' +require 'veritas/sql/generator/core_ext/date' +require 'veritas/sql/generator/core_ext/date_time' require 'veritas/sql/generator/visitor' require 'veritas/sql/generator/identifier' require 'veritas/sql/generator/attribute' require 'veritas/sql/generator/direction' require 'veritas/sql/generator/literal' -require 'veritas/sql/generator/logic' +require 'veritas/sql/generator/function' +require 'veritas/sql/generator/function/aggregate' +require 'veritas/sql/generator/function/connective' +require 'veritas/sql/generator/function/numeric' +require 'veritas/sql/generator/function/predicate' +require 'veritas/sql/generator/function/proposition' +require 'veritas/sql/generator/function/string' + require 'veritas/sql/generator/relation' require 'veritas/sql/generator/relation/unary' require 'veritas/sql/generator/relation/base' require 'veritas/sql/generator/relation/binary' require 'veritas/sql/generator/relation/set' @@ -27,9 +35,24 @@ module SQL module Generator # Raised when an invalid relation is visited class InvalidRelationError < StandardError; end + + LEFT_PARENTHESIS = '('.freeze + RIGHT_PARENTHESIS = ')'.freeze + + # Return a parenthesized SQL statement (inline modification) + # + # @param [#to_s] sql + # + # @return [#to_s] + # same instance as sql + # + # @api private + def self.parenthesize!(sql) + sql.insert(0, LEFT_PARENTHESIS) << RIGHT_PARENTHESIS + end end # module Generator end # module SQL end # module Veritas