Sha256: 50b794bb8e61cf4e5b26ae8b19036fac129e18a8042c480e08878da5c2587c8b

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

# rubocop:disable Naming/MethodName
# rubocop:disable Naming/UncommunicativeMethodParamName
# rubocop:disable Metrics/CyclomaticComplexity
# rubocop:disable Metrics/AbcSize

module Arel
  module Nodes
    # https://www.postgresql.org/docs/8.3/tutorial-transactions.html
    class Transaction < Arel::Nodes::Binary
      alias type left
      alias options right
    end
  end

  module Visitors
    class ToSql
      def visit_Arel_Nodes_Transaction(o, collector)
        case o.type
        when 1
          collector << 'BEGIN'
        when 3
          collector << 'COMMIT'
        when 4
          collector << 'ROLLBACK'
        when 5
          collector << 'SAVEPOINT '
          collector << o.right
        when 6
          collector << 'RELEASE SAVEPOINT '
          collector << o.right
        when 7
          collector << 'ROLLBACK TO '
          collector << o.right
        else
          raise "Unknown transaction type `#{o.type}`"
        end
      end
    end
  end
end

# rubocop:enable Naming/MethodName
# rubocop:enable Naming/UncommunicativeMethodParamName
# rubocop:enable Metrics/CyclomaticComplexity
# rubocop:enable Metrics/AbcSize

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
arel_toolkit-0.4.9 lib/arel/extensions/transaction.rb
arel_toolkit-0.4.8 lib/arel/extensions/transaction.rb
arel_toolkit-0.4.7 lib/arel/extensions/transaction.rb
arel_toolkit-0.4.6 lib/arel/extensions/transaction.rb