Sha256: d7be394ebfcf5528d63170ad3b2a60af9f1d2b4345642883c373d805eabccb3a

Contents?: true

Size: 1.55 KB

Versions: 2

Compression:

Stored size: 1.55 KB

Contents

# frozen_string_literal: true

module ActiveRecord
  module ConnectionAdapters
    module CockroachDB
      module ColumnMethods
        def spatial(name, options = {})
          raise "You must set a type. For example: 't.spatial type: :st_point'" unless options[:type]

          column(name, options[:type], **options)
        end

        def geography(name, options = {})
          column(name, :geography, **options)
        end

        def geometry(name, options = {})
          column(name, :geometry, **options)
        end

        def geometry_collection(name, options = {})
          column(name, :geometry_collection, **options)
        end

        def line_string(name, options = {})
          column(name, :line_string, **options)
        end

        def multi_line_string(name, options = {})
          column(name, :multi_line_string, **options)
        end

        def multi_point(name, options = {})
          column(name, :multi_point, **options)
        end

        def multi_polygon(name, options = {})
          column(name, :multi_polygon, **options)
        end

        def st_point(name, options = {})
          column(name, :st_point, **options)
        end

        def st_polygon(name, options = {})
          column(name, :st_polygon, **options)
        end

        private

        def valid_column_definition_options
          spatial = [:srid, :has_z, :has_m, :geographic, :spatial_type]
          crdb = [:hidden]
          super + spatial + crdb
        end
      end
    end

    PostgreSQL::Table.include CockroachDB::ColumnMethods
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activerecord-cockroachdb-adapter-7.1.1 lib/active_record/connection_adapters/cockroachdb/column_methods.rb
activerecord-cockroachdb-adapter-7.1.0 lib/active_record/connection_adapters/cockroachdb/column_methods.rb