Skip to content

Commit

Permalink
Merge pull request #385 from WelcomeHomes/master
Browse files Browse the repository at this point in the history
Pass new identity attribute to preserve argument order
  • Loading branch information
keithdoggett committed Oct 16, 2023
2 parents 3527a41 + 7778ebe commit 75dc149
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Expand Up @@ -8,7 +8,7 @@ module SchemaStatements
# https://github.com/rails/rails/blob/7-0-stable/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb#L662
# Create a SpatialColumn instead of a PostgreSQL::Column
def new_column_from_field(table_name, field, _definitions)
column_name, type, default, notnull, oid, fmod, collation, comment, attgenerated = field
column_name, type, default, notnull, oid, fmod, collation, comment, identity, attgenerated = field
type_metadata = fetch_type_metadata(column_name, type, oid.to_i, fmod.to_i)
default_value = extract_value_from_default(default)

Expand All @@ -35,6 +35,7 @@ def new_column_from_field(table_name, field, _definitions)
comment: comment.presence,
serial: serial,
generated: attgenerated,
identity: identity.presence,
spatial: spatial
)
end
Expand Down
Expand Up @@ -9,7 +9,7 @@ class SpatialColumn < ConnectionAdapters::PostgreSQLColumn # :nodoc:
# "Geography(Point,4326)"
def initialize(name, default, sql_type_metadata = nil, null = true,
default_function = nil, collation: nil, comment: nil,
serial: nil, generated: nil, spatial: nil)
serial: nil, generated: nil, spatial: nil, identity: nil)
@sql_type_metadata = sql_type_metadata
@geographic = !!(sql_type_metadata.sql_type =~ /geography\(/i)
if spatial
Expand All @@ -31,7 +31,7 @@ def initialize(name, default, sql_type_metadata = nil, null = true,
build_from_sql_type(sql_type_metadata.sql_type)
end
super(name, default, sql_type_metadata, null, default_function,
collation: collation, comment: comment, serial: serial, generated: generated)
collation: collation, comment: comment, serial: serial, generated: generated, identity: identity)
if spatial? && @srid
@limit = { srid: @srid, type: to_type_name(geometric_type) }
@limit[:has_z] = true if @has_z
Expand Down

0 comments on commit 75dc149

Please sign in to comment.