spatial_features 3.10.0 → 3.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a5ada735515d4ec029917c5d00994254804e9b270c65093f32672d851fb1a452
4
- data.tar.gz: 1828f79799ab6e91bfcd0503aba6091b9e0120d33aa28a05158f729dc1738e0f
3
+ metadata.gz: 4c0e0009e894639d857055d9352765ff673d5d3759bc12b7382f132fd72af923
4
+ data.tar.gz: 6ecc2848af239c202773a3e80522fa8172619808254fd5ad39c15e20708abf2b
5
5
  SHA512:
6
- metadata.gz: ff7491b8acd5875ad23909d2ce988ea793d00707be4ece7d9cb7b700c4a1e064db949778ccc029f948f3ea389d91b7e8c54dceac55fb3206bd928bd97319e760
7
- data.tar.gz: f1256bec3bb256e2789e3e7e0462f8f710f23fc1a493814b8a9126c3cd5495680394f588ca5121908875847d5ae3748a10a0e65d5b0f84d7ee65a5304a238c4b
6
+ metadata.gz: e7da7be9e6b5bb1ec0db3980ca273e8ce0156be36ea3b00a06b6c5d60316ed9b19960b9d0ebf7803ec71147f5b0e72c85028e3f64acc75f2d8b47bd5d2a924b6
7
+ data.tar.gz: 32ac8b571dd0d223145c5980b56d040ba7daa3fc5070558c192267011a735a95e0d0088332047ccba75f3bad9a2aa5b7aa7f575f1555b3457f4c8275fad243ca
@@ -56,24 +56,23 @@ module SpatialFeatures
56
56
  end
57
57
 
58
58
  def geom_from_kml(kml)
59
- geom = nil
60
- conn = nil
61
-
62
59
  strip_altitude(kml)
63
60
 
64
- # Do query in a new thread so we use a new connection (if the query fails it will poison the transaction of the current connection)
65
- #
66
- # We manually checkout a new connection since Rails re-uses DB connections across threads.
67
- Thread.new do
68
- conn = ActiveRecord::Base.connection_pool.checkout
69
- geom = conn.select_value("SELECT ST_GeomFromKML(#{conn.quote(kml.to_s)})")
70
- rescue ActiveRecord::StatementInvalid => e # Discard Invalid KML features
71
- geom = nil
72
- ensure
73
- ActiveRecord::Base.connection_pool.checkin(conn) if conn
74
- end.join
75
-
76
- return geom
61
+ # Run the parse inside a SAVEPOINT so a `ST_GeomFromKML` failure on a single
62
+ # invalid feature rolls back only that savepoint, not the surrounding
63
+ # transaction. The previous implementation spawned a thread and checked out
64
+ # a fresh connection for the same isolation reason, but on Rails 8 that
65
+ # pattern deadlocks under `use_transactional_fixtures` — the test pins its
66
+ # connection, the spawned thread blocks indefinitely waiting on
67
+ # `ActiveRecord::Base.connection_pool.checkout`. A nested transaction
68
+ # (`requires_new: true`) gives identical fault containment without crossing
69
+ # thread boundaries.
70
+ ActiveRecord::Base.transaction(requires_new: true) do
71
+ conn = ActiveRecord::Base.connection
72
+ conn.select_value("SELECT ST_GeomFromKML(#{conn.quote(kml.to_s)})")
73
+ end
74
+ rescue ActiveRecord::StatementInvalid # Discard invalid KML features
75
+ nil
77
76
  end
78
77
 
79
78
  def images_from_metadata(metadata)
@@ -1,3 +1,3 @@
1
1
  module SpatialFeatures
2
- VERSION = "3.10.0"
2
+ VERSION = "3.10.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spatial_features
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.10.0
4
+ version: 3.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Wallace
@@ -235,7 +235,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
235
235
  - !ruby/object:Gem::Version
236
236
  version: '0'
237
237
  requirements: []
238
- rubygems_version: 3.7.2
238
+ rubygems_version: 4.0.5
239
239
  specification_version: 4
240
240
  summary: Adds spatial methods to a model.
241
241
  test_files: []