Sha256: e897c7697bbbe63cc9669ccf38a80a5019b3e82f9f719b2b9d1f56ca31e63e76

Contents?: true

Size: 530 Bytes

Versions: 4

Compression:

Stored size: 530 Bytes

Contents

# frozen_string_literal: true

module AR
  module Sequence
    module ModelMethods
      def nextval(name)
        name = connection.quote(name)
        connection.execute("SELECT nextval(#{name})").first["nextval"]
      end

      def currval(name)
        name = connection.quote(name)
        connection.execute("SELECT currval(#{name})").first["currval"]
      end

      def setval(name, value)
        name = connection.quote(name)
        connection.execute("SELECT setval(#{name}, #{value})")
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ar-sequence-0.2.1 lib/ar/sequence/model_methods.rb
ar-sequence-0.2.0 lib/ar/sequence/model_methods.rb
ar-sequence-0.1.2 lib/ar/sequence/model_methods.rb
ar-sequence-0.1.1 lib/ar/sequence/model_methods.rb