Skip to content

Commit ae9c973

Browse files
committed
fix: ensure type_map gets sql type details
In our adapter, we rely on the sql type string for spatial details to properly map the type to the correct ActiveRecord type. It was not shared.
1 parent 1770c41 commit ae9c973

File tree

1 file changed

+15
-0
lines changed
  • lib/active_record/connection_adapters/cockroachdb

1 file changed

+15
-0
lines changed

lib/active_record/connection_adapters/cockroachdb/quoting.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,21 @@ def quoted_date(value)
5959
# This is tested by `BasicsTest#test_default_in_local_time`.
6060
super + value.strftime("%z")
6161
end
62+
63+
# NOTE: This method should be private in future rails versions.
64+
# Hence we should also make it private then.
65+
#
66+
# See https://github.com/rails/rails/blob/v8.1.1/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb#L190
67+
def lookup_cast_type(sql_type)
68+
type_map.lookup(
69+
# oid
70+
query_value("SELECT #{quote(sql_type)}::regtype::oid", "SCHEMA").to_i,
71+
# fmod, not needed.
72+
nil,
73+
# details needed for `..::CockroachDB::OID::Spatial` (e.g. `geometry(point,3857)`)
74+
sql_type
75+
)
76+
end
6277
end
6378
end
6479
end

0 commit comments

Comments
 (0)