Skip to content

Commit

Permalink
fix(column): avoid monkeypatching pg
Browse files Browse the repository at this point in the history
Fixes #251
  • Loading branch information
BuonOmo committed Aug 13, 2023
1 parent 269001e commit 636a2ed
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 1 addition & 5 deletions lib/active_record/connection_adapters/cockroachdb/column.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module ActiveRecord
module ConnectionAdapters
module CockroachDB
module PostgreSQLColumnMonkeyPatch
class Column < PostgreSQLColumn
# most functions taken from activerecord-postgis-adapter spatial_column
# https://github.com/rgeo/activerecord-postgis-adapter/blob/master/lib/active_record/connection_adapters/postgis/spatial_column.rb
def initialize(name, default, sql_type_metadata = nil, null = true,
Expand Down Expand Up @@ -93,9 +93,5 @@ def to_type_name(geometric_type)
end
end
end

class PostgreSQLColumn
prepend CockroachDB::PostgreSQLColumnMonkeyPatch
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def new_column_from_field(table_name, field)
# {:dimension=>2, :has_m=>false, :has_z=>false, :name=>"latlon", :srid=>0, :type=>"GEOMETRY"}
spatial = spatial_column_info(table_name).get(column_name, type_metadata.sql_type)

PostgreSQL::Column.new(
CockroachDB::Column.new(
column_name,
default_value,
type_metadata,
Expand All @@ -112,7 +112,7 @@ def new_column_from_field(table_name, field)
# since type alone is not enough to format the column.
# Ex. type_to_sql(:geography, limit: "Point,4326")
# => "geography(Point,4326)"
#
#
def type_to_sql(type, limit: nil, precision: nil, scale: nil, array: nil, **) # :nodoc:
sql = \
case type.to_s
Expand Down

0 comments on commit 636a2ed

Please sign in to comment.