Sha256: 9848fc9c0d889d1bdf07020e756a18bb664bf8642561bd8ec24ffdb6ac32f255

Contents?: true

Size: 1.2 KB

Versions: 10

Compression:

Stored size: 1.2 KB

Contents

# rubocop:disable Naming/MethodName
# rubocop:disable Naming/UncommunicativeMethodParamName

module Arel
  module Nodes
    # https://www.postgresql.org/docs/9.3/sql-set.html
    class VariableSet < Arel::Nodes::Node
      attr_reader :type
      attr_reader :args
      attr_reader :name
      attr_reader :local

      def initialize(type, args, name, local)
        @type = type
        @args = args
        @name = name
        @local = local
      end
    end
  end

  module Visitors
    class ToSql
      def visit_Arel_Nodes_VariableSet(o, collector)
        collector << 'SET '
        collector << 'LOCAL ' if o.local

        if o.name == 'timezone'
          collector << 'TIME ZONE '
        else
          collector << o.name
          collector << ' TO '
        end

        if o.args.empty?
          collector << 'DEFAULT'
        else
          inject_join(o.args, collector, ', ')
        end
      end
    end

    class Dot
      def visit_Arel_Nodes_VariableSet(o)
        visit_edge o, 'type'
        visit_edge o, 'args'
        visit_edge o, 'name'
        visit_edge o, 'local'
      end
    end
  end
end

# rubocop:enable Naming/MethodName
# rubocop:enable Naming/UncommunicativeMethodParamName

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
arel_toolkit-0.4.9 lib/arel/extensions/variable_set.rb
arel_toolkit-0.4.8 lib/arel/extensions/variable_set.rb
arel_toolkit-0.4.7 lib/arel/extensions/variable_set.rb
arel_toolkit-0.4.6 lib/arel/extensions/variable_set.rb
arel_toolkit-0.4.5 lib/arel/extensions/variable_set.rb
arel_toolkit-0.4.4 lib/arel/extensions/variable_set.rb
arel_toolkit-0.4.3 lib/arel/extensions/variable_set.rb
arel_toolkit-0.4.2 lib/arel/extensions/variable_set.rb
arel_toolkit-0.4.1 lib/arel/extensions/variable_set.rb
arel_toolkit-0.4.0 lib/arel/extensions/variable_set.rb