Sha256: 7635d96772257443f809a61b1e88cbc69eedc5f3b480e35628e20bba577af1ca

Contents?: true

Size: 915 Bytes

Versions: 6

Compression:

Stored size: 915 Bytes

Contents

# frozen_string_literal: true

module Arel  # :nodoc:
  module Visitors  # :nodoc:
    # Different super-class under JRuby JDBC adapter.
    PostGISSuperclass = if defined?(::ArJdbc::PostgreSQL::BindSubstitution)
                          ::ArJdbc::PostgreSQL::BindSubstitution
                        else
                          PostgreSQL
                        end

    class PostGIS < PostGISSuperclass  # :nodoc:
      include RGeo::ActiveRecord::SpatialToSql

      FUNC_MAP = {
        "st_wkttosql" => "ST_GeomFromEWKT",
      }

      def st_func(standard_name)
        FUNC_MAP[standard_name.downcase] || standard_name
      end

      def visit_String(node, collector)
        collector << "#{st_func('ST_WKTToSQL')}(#{quote(node)})"
      end

      def visit_RGeo_ActiveRecord_SpatialNamedFunction(node, collector)
        aggregate(st_func(node.name), node, collector)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
activerecord-postgis-adapter-6.0.3 lib/active_record/connection_adapters/postgis/arel_tosql.rb
activerecord-postgis-adapter-6.0.2 lib/active_record/connection_adapters/postgis/arel_tosql.rb
activerecord-postgis-adapter-5.2.3 lib/active_record/connection_adapters/postgis/arel_tosql.rb
activerecord-postgis-adapter-6.0.1 lib/active_record/connection_adapters/postgis/arel_tosql.rb
activerecord-postgis-adapter-6.0.0 lib/active_record/connection_adapters/postgis/arel_tosql.rb
activerecord-postgis-adapter-5.2.2 lib/active_record/connection_adapters/postgis/arel_tosql.rb