Sha256: e69a47ce5f3c83d9eeda68728bda8a507b85afef4b54b249eafdd20a8dbb1b20

Contents?: true

Size: 1.1 KB

Versions: 21

Compression:

Stored size: 1.1 KB

Contents

require 'dry/core/cache'

module ROM
  module SQL
    # Used as a pair table name + field name.
    # Similar to Sequel::SQL::QualifiedIdentifier but we don't want
    # Sequel types to leak into ROM
    #
    # @api private
    class QualifiedAttribute
      include Dry::Equalizer(:dataset, :attribute)

      extend Dry::Core::Cache

      # Dataset (table) name
      #
      # @api private
      attr_reader :dataset

      # Attribute (field, column) name
      #
      # @api private
      attr_reader :attribute

      # @api private
      def self.[](*args)
        fetch_or_store(args) { new(*args) }
      end

      # @api private
      def initialize(dataset, attribute)
        @dataset = dataset
        @attribute = attribute
      end

      # Used by Sequel for building SQL statements
      #
      # @api private
      def sql_literal_append(ds, sql)
        ds.qualified_identifier_sql_append(sql, dataset, attribute)
      end

      # Convinient interface for attribute names
      #
      # @return [Symbol]
      #
      # @api private
      def to_sym
        attribute
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
rom-sql-1.3.5 lib/rom/sql/qualified_attribute.rb
rom-sql-1.3.4 lib/rom/sql/qualified_attribute.rb
rom-sql-1.3.3 lib/rom/sql/qualified_attribute.rb
rom-sql-1.3.2 lib/rom/sql/qualified_attribute.rb
rom-sql-1.3.1 lib/rom/sql/qualified_attribute.rb
rom-sql-1.3.0 lib/rom/sql/qualified_attribute.rb
rom-sql-1.2.2 lib/rom/sql/qualified_attribute.rb
rom-sql-1.2.1 lib/rom/sql/qualified_attribute.rb
rom-sql-1.2.0 lib/rom/sql/qualified_attribute.rb
rom-sql-1.1.2 lib/rom/sql/qualified_attribute.rb
rom-sql-1.1.1 lib/rom/sql/qualified_attribute.rb
rom-sql-1.1.0 lib/rom/sql/qualified_attribute.rb
rom-sql-1.0.3 lib/rom/sql/qualified_attribute.rb
rom-sql-1.0.2 lib/rom/sql/qualified_attribute.rb
rom-sql-1.0.1 lib/rom/sql/qualified_attribute.rb
rom-sql-1.0.0 lib/rom/sql/qualified_attribute.rb
rom-sql-1.0.0.rc2 lib/rom/sql/qualified_attribute.rb
rom-sql-1.0.0.rc1 lib/rom/sql/qualified_attribute.rb
rom-sql-1.0.0.beta3 lib/rom/sql/qualified_attribute.rb
rom-sql-1.0.0.beta2 lib/rom/sql/qualified_attribute.rb