activerecord-postgis 0.1.0 → 0.2.0

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: d2022a537c5f4ac8fcdff4b7e9fb5a8801167da139a23df3095c66c5da4cad86
4
- data.tar.gz: 174ed2a80856954bc39fae2bd479c47d3508f50ae5ed5ba2dfea458b2741a955
3
+ metadata.gz: b452469d6861f42a259853b4f6b3f7e5a694d98c325141d5a43ac09eaf40e967
4
+ data.tar.gz: ada960ed4d93542ae2f2f805412d8b39dc58ae52cfa1612b8007e53e2bf2952f
5
5
  SHA512:
6
- metadata.gz: a5c66a366cf6e101c9adb412abc8f5714299f9d38c005125a9fff1ba54d0621190acdd391b7fcdf99f16bbf36a59b45a6504d99ef6fffa4d0165f6acff5db8e4
7
- data.tar.gz: 2ba4c06a28dbef90a5aff91db38732e6df62cb9d19f65d363b883d5b49e8895aba4622c9b6f81f21892812b201c88a8c8310e6f2c027404d339ab00a29c237e3
6
+ metadata.gz: d3c0f7fa79a22ba014655f18198bc4c048f3287fa6ade5e5c1442e8f0099c910394bc7592939b3a8c911670d9c4a54b5bbb8d0d29b568dddaf0406cba310c453
7
+ data.tar.gz: 14c0462864a39e967b1c2c684a0dda6a6e0d6b1d902c87561398dc214f4934238594f8847b26ba33e52df669f00d998828df0c2ca29305fc56f94209e45019bc
@@ -64,6 +64,11 @@ module ActiveRecord
64
64
  geom_type = $2
65
65
  srid = $3&.to_i
66
66
 
67
+ # Add geographic option for geography columns
68
+ if spatial_type.downcase == "geography"
69
+ spec[:geographic] = true
70
+ end
71
+
67
72
  # Add SRID if not default
68
73
  if srid && srid != default_srid(spatial_type)
69
74
  spec[:srid] = srid
@@ -7,8 +7,8 @@ module ActiveRecord
7
7
  module PostGIS
8
8
  module Type
9
9
  class Geometry < Spatial
10
- def initialize(srid: 0, has_z: false, has_m: false)
11
- super(geo_type: "geometry", srid: srid, has_z: has_z, has_m: has_m)
10
+ def initialize(srid: 0, has_z: false, has_m: false, geographic: false)
11
+ super(geo_type: "geometry", srid: srid, has_z: has_z, has_m: has_m, geographic: geographic)
12
12
  end
13
13
 
14
14
  def type
@@ -7,8 +7,8 @@ module ActiveRecord
7
7
  module PostGIS
8
8
  module Type
9
9
  class GeometryCollection < Spatial
10
- def initialize(srid: 0, has_z: false, has_m: false)
11
- super(geo_type: "geometry_collection", srid: srid, has_z: has_z, has_m: has_m)
10
+ def initialize(srid: 0, has_z: false, has_m: false, geographic: false)
11
+ super(geo_type: "geometry_collection", srid: srid, has_z: has_z, has_m: has_m, geographic: geographic)
12
12
  end
13
13
 
14
14
  def type
@@ -7,8 +7,8 @@ module ActiveRecord
7
7
  module PostGIS
8
8
  module Type
9
9
  class MultiLineString < Spatial
10
- def initialize(srid: 0, has_z: false, has_m: false)
11
- super(geo_type: "multi_line_string", srid: srid, has_z: has_z, has_m: has_m)
10
+ def initialize(srid: 0, has_z: false, has_m: false, geographic: false)
11
+ super(geo_type: "multi_line_string", srid: srid, has_z: has_z, has_m: has_m, geographic: geographic)
12
12
  end
13
13
 
14
14
  def type
@@ -7,8 +7,8 @@ module ActiveRecord
7
7
  module PostGIS
8
8
  module Type
9
9
  class MultiPoint < Spatial
10
- def initialize(srid: 0, has_z: false, has_m: false)
11
- super(geo_type: "multi_point", srid: srid, has_z: has_z, has_m: has_m)
10
+ def initialize(srid: 0, has_z: false, has_m: false, geographic: false)
11
+ super(geo_type: "multi_point", srid: srid, has_z: has_z, has_m: has_m, geographic: geographic)
12
12
  end
13
13
 
14
14
  def type
@@ -7,8 +7,8 @@ module ActiveRecord
7
7
  module PostGIS
8
8
  module Type
9
9
  class Polygon < Spatial
10
- def initialize(srid: 0, has_z: false, has_m: false)
11
- super(geo_type: "polygon", srid: srid, has_z: has_z, has_m: has_m)
10
+ def initialize(srid: 0, has_z: false, has_m: false, geographic: false)
11
+ super(geo_type: "polygon", srid: srid, has_z: has_z, has_m: has_m, geographic: geographic)
12
12
  end
13
13
 
14
14
  def type
@@ -3,7 +3,7 @@
3
3
  module ActiveRecord
4
4
  module ConnectionAdapters
5
5
  module PostGIS
6
- VERSION = "0.1.0"
6
+ VERSION = "0.2.0"
7
7
  end
8
8
  end
9
9
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "active_record/connection_adapters/postgresql_adapter"
3
4
  require_relative "postgis/version"
4
5
  require_relative "postgis/type/geography"
5
6
  require_relative "postgis/type/geometry"
@@ -37,18 +38,18 @@ module ActiveRecord
37
38
  @initialized = true
38
39
 
39
40
  # Extend PostgreSQL Column class with spatial functionality
40
- ActiveRecord::ConnectionAdapters::PostgreSQL::Column.include(ColumnExtensions)
41
+ PostgreSQL::Column.include(ColumnExtensions)
41
42
 
42
43
  # Add spatial object quoting support
43
- ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend(Quoting)
44
+ PostgreSQLAdapter.prepend(Quoting)
44
45
 
45
46
  # Allow PostGIS specific options in table definitions
46
47
  # The `define_column_methods` call already makes these available on the `TableDefinition` instance.
47
48
  # The issue might be deeper in how schema.rb is processed or how options are validated.
48
49
  # Let's ensure that the column methods are defined *before* any schema loading that might trigger validation.
49
50
 
50
- ActiveRecord::ConnectionAdapters::PostgreSQL::Table.include(
51
- ActiveRecord::ConnectionAdapters::PostGIS::TableDefinition
51
+ PostgreSQL::Table.include(
52
+ PostGIS::TableDefinition
52
53
  )
53
54
 
54
55
  # Using st_* prefix to avoid conflicts with PostgreSQL native geometric types
@@ -74,7 +75,7 @@ module ActiveRecord
74
75
 
75
76
 
76
77
  # Tell Rails these are valid column methods for schema dumping - PostgreSQL only
77
- ActiveRecord::ConnectionAdapters::PostgreSQL::TableDefinition.send(:define_column_methods,
78
+ PostgreSQL::TableDefinition.send(:define_column_methods,
78
79
  :st_geography, :st_geometry, :st_geometry_collection, :st_line_string,
79
80
  :st_multi_line_string, :st_multi_point, :st_multi_polygon, :st_point, :st_polygon,
80
81
  # Legacy column methods for compatibility with activerecord-postgis-adapter
@@ -83,10 +84,10 @@ module ActiveRecord
83
84
  *SPATIAL_OPTIONS_FOR_REGISTRATION)
84
85
 
85
86
  # prevent unknown OID warning and register PostGIS types
86
- ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.singleton_class.prepend(RegisterTypes)
87
+ PostgreSQLAdapter.singleton_class.prepend(RegisterTypes)
87
88
 
88
89
  # Prepend our extensions to handle spatial columns
89
- ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend(AdapterExtensions)
90
+ PostgreSQLAdapter.prepend(AdapterExtensions)
90
91
 
91
92
  # Register spatial types with ActiveRecord::Type - use st_* prefix to avoid conflicts
92
93
  adapter_name = :postgresql
@@ -113,7 +114,7 @@ module ActiveRecord
113
114
  ActiveRecord::Type.register(:polygon, Type::Polygon, adapter: adapter_name)
114
115
 
115
116
  # Ignore PostGIS system tables in schema dumps - PostgreSQL specific
116
- ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaDumper.ignore_tables |= %w[
117
+ PostgreSQL::SchemaDumper.ignore_tables |= %w[
117
118
  geography_columns
118
119
  geometry_columns
119
120
  layer
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # dependencies
4
3
  require "active_support"
5
4
  require "active_record"
5
+ require "active_record/connection_adapters"
6
+ require_relative "active_record/connection_adapters/postgis"
7
+ require "rgeo-activerecord"
6
8
 
7
9
  # Initialize when PostgreSQL adapter is loaded
8
10
  ActiveSupport.on_load(:active_record_postgresqladapter) do
9
- require "rgeo-activerecord"
10
- require_relative "active_record/connection_adapters/postgis"
11
11
  ActiveRecord::ConnectionAdapters::PostGIS.initialize!
12
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-postgis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdelkader Boudih