Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix SchemaStatements#initialize_type_map
Since the Rails 6 upgrade, we started seeing some random PostGIS serialization/deserialization issues, debugging the issues shows that the ActiveRecord connection `type_map` isn't initialized properly. It does not contain the PostGIS OID mappings that are retrieved in [`load_additional_types`](https://github.com/rgeo/activerecord-postgis-adapter/blob/cc0e3f53520feed0b43800d8ee86561ee03de413/lib/active_record/connection_adapters/postgis/schema_statements.rb#L87-L105). Usually, Rails would add missing OID mappings when encountered, however, there are code paths that go around this (See [`lookup_cast_type_from_column`](https://github.com/rails/rails/blob/15748f6a052d4df68b6acf66456c181b42d9fe25/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb#L78)). This is most likely a bug in Rails internals. This patch fixes the [`initialize_type_map`](https://github.com/rgeo/activerecord-postgis-adapter/blob/cc0e3f53520feed0b43800d8ee86561ee03de413/lib/active_record/connection_adapters/postgis/schema_statements.rb#L87-L105) method by ensuring that the specific PostGIS types are registered before calling `super` which will then call `load_additional_types` and registers the other PostGIS OIDs. This patch should solve rgeo#307 and rgeo#308.
- Loading branch information