activerecord-postgis-adapter 8.0.0 → 8.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88b08c026151d4f1a930e5fc3299bbf1898a20df441f86b57cde0aabcd29b4cb
4
- data.tar.gz: 823b5b9511687fa663273242d5cce9d490610b813df495ad81b43c241c3b443e
3
+ metadata.gz: d0e36778a7f367dc3b7477d7f389d94360b0f9130791cea0120b81f0feef745b
4
+ data.tar.gz: 29d1233c9abbd1bbf0b0325310acb5a23eca2ba9baab7756729c2ea2bf6d14ec
5
5
  SHA512:
6
- metadata.gz: f851b74ce6e9da1a4aac3bfcf8acbda44e563f049de04eaf832a8b49cf2acc41cf98495a9ff123786d9bd871658d97637453ae6d845e55f0bf4f5074db01eab7
7
- data.tar.gz: 7e47c25711cf8ee49c62a8ad89f9d0b0e5525bf4fb1b45ddb185db6477d0e114a4868a50c612e9a51e880499213cb6cb82f051adf993618eb0978cc0d0f45dc7
6
+ metadata.gz: ce7fda2c1d2baa1a4ab7ba120ad643468e12ed68b7e7100e5a1ef002e803fac5c8b764514d108986942e41729809b24ef31e7a6b75b14658bfe6bbb5e5407fad
7
+ data.tar.gz: 7e7d8e706991da86fb963735a67f1f28a9e97d258bf1fe099d6f61f449e0f16064909f2a96614fa8737e87cd31c2f99c3982d8d5e6da782f29a3a01bfbc6886b
@@ -5,18 +5,17 @@ module ActiveRecord
5
5
  module PostGIS
6
6
  module SchemaStatements
7
7
  # override
8
- # https://github.com/rails/rails/blob/6-0-stable/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb#L624
8
+ # https://github.com/rails/rails/blob/7-0-stable/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb#L662
9
9
  # Create a SpatialColumn instead of a PostgreSQL::Column
10
10
  def new_column_from_field(table_name, field)
11
- column_name, type, default, notnull, oid, fmod, collation, comment = field
11
+ column_name, type, default, notnull, oid, fmod, collation, comment, attgenerated = field
12
12
  type_metadata = fetch_type_metadata(column_name, type, oid.to_i, fmod.to_i)
13
13
  default_value = extract_value_from_default(default)
14
14
  default_function = extract_default_function(default_value, default)
15
15
 
16
- serial =
17
- if (match = default_function&.match(/\Anextval\('"?(?<sequence_name>.+_(?<suffix>seq\d*))"?'::regclass\)\z/))
18
- sequence_name_from_parts(table_name, column_name, match[:suffix]) == match[:sequence_name]
19
- end
16
+ if match = default_function&.match(/\Anextval\('"?(?<sequence_name>.+_(?<suffix>seq\d*))"?'::regclass\)\z/)
17
+ serial = sequence_name_from_parts(table_name, column_name, match[:suffix]) == match[:sequence_name]
18
+ end
20
19
 
21
20
  # {:dimension=>2, :has_m=>false, :has_z=>false, :name=>"latlon", :srid=>0, :type=>"GEOMETRY"}
22
21
  spatial = spatial_column_info(table_name).get(column_name, type_metadata.sql_type)
@@ -30,49 +29,11 @@ module ActiveRecord
30
29
  collation: collation,
31
30
  comment: comment.presence,
32
31
  serial: serial,
32
+ generated: attgenerated,
33
33
  spatial: spatial
34
34
  )
35
35
  end
36
36
 
37
- # override
38
- # https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb#L544
39
- #
40
- # returns Postgresql sql type string
41
- # examples:
42
- # "geometry(Point,4326)"
43
- # "geography(Point,4326)"
44
- #
45
- # note: type alone is not enough to detect the sql type,
46
- # so `limit` is used to pass the additional information. :(
47
- #
48
- # type_to_sql(:geography, limit: "Point,4326")
49
- # => "geography(Point,4326)"
50
- def type_to_sql(type, limit: nil, precision: nil, scale: nil, array: nil, **)
51
- case type.to_s
52
- when "geometry", "geography"
53
- "#{type}(#{limit})"
54
- else
55
- super
56
- end
57
- end
58
-
59
- # override
60
- def native_database_types
61
- # Add spatial types
62
- super.merge(
63
- geography: { name: "geography" },
64
- geometry: { name: "geometry" },
65
- geometry_collection: { name: "geometry_collection" },
66
- line_string: { name: "line_string" },
67
- multi_line_string: { name: "multi_line_string" },
68
- multi_point: { name: "multi_point" },
69
- multi_polygon: { name: "multi_polygon" },
70
- spatial: { name: "geometry" },
71
- st_point: { name: "st_point" },
72
- st_polygon: { name: "st_polygon" }
73
- )
74
- end
75
-
76
37
  # override
77
38
  def create_table_definition(*args, **kwargs)
78
39
  PostGIS::TableDefinition.new(self, *args, **kwargs)
@@ -9,7 +9,7 @@ module ActiveRecord # :nodoc:
9
9
  # "Geography(Point,4326)"
10
10
  def initialize(name, default, sql_type_metadata = nil, null = true,
11
11
  default_function = nil, collation: nil, comment: nil,
12
- serial: nil, spatial: nil)
12
+ serial: nil, generated: nil, spatial: nil)
13
13
  @sql_type_metadata = sql_type_metadata
14
14
  @geographic = !!(sql_type_metadata.sql_type =~ /geography\(/i)
15
15
  if spatial
@@ -31,7 +31,7 @@ module ActiveRecord # :nodoc:
31
31
  build_from_sql_type(sql_type_metadata.sql_type)
32
32
  end
33
33
  super(name, default, sql_type_metadata, null, default_function,
34
- collation: collation, comment: comment, serial: serial)
34
+ collation: collation, comment: comment, serial: serial, generated: generated)
35
35
  if spatial? && @srid
36
36
  @limit = { srid: @srid, type: to_type_name(geometric_type) }
37
37
  @limit[:has_z] = true if @has_z
@@ -3,7 +3,7 @@
3
3
  module ActiveRecord
4
4
  module ConnectionAdapters
5
5
  module PostGIS
6
- VERSION = "8.0.0"
6
+ VERSION = "8.0.1"
7
7
  end
8
8
  end
9
9
  end
@@ -90,6 +90,24 @@ module ActiveRecord
90
90
 
91
91
  super
92
92
  end
93
+
94
+ def native_database_types
95
+ @native_database_types ||= begin
96
+ default_types = PostgreSQLAdapter.native_database_types
97
+ default_types.merge({
98
+ geography: { name: "geography" },
99
+ geometry: { name: "geometry" },
100
+ geometry_collection: { name: "geometry_collection" },
101
+ line_string: { name: "line_string" },
102
+ multi_line_string: { name: "multi_line_string" },
103
+ multi_point: { name: "multi_point" },
104
+ multi_polygon: { name: "multi_polygon" },
105
+ spatial: { name: "geometry" },
106
+ st_point: { name: "st_point" },
107
+ st_polygon: { name: "st_polygon" }
108
+ })
109
+ end
110
+ end
93
111
  end
94
112
 
95
113
  def srs_database_columns
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-postgis-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.0
4
+ version: 8.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Azuma
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-01-03 00:00:00.000000000 Z
12
+ date: 2022-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord