Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(column): avoid monkeypatching pg #271

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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