Skip to content

Conversation

@modosc
Copy link

@modosc modosc commented Jul 24, 2025

fixes #432

@modosc modosc marked this pull request as ready for review July 24, 2025 17:18
Comment on lines +214 to +215
SpatialModel.lease_connection.create_enum(:point_type, ["point", "line_string", "polygon"])
SpatialModel.lease_connection.create_table(:spatial_models, force: true) do |t|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it properly cleanup afterwards ? If so, how ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't know - i copied this from the other examples, can you point me to where any explicit cleanup happens?

Comment on lines +216 to +218
t.column "latlon", :st_point, srid: 3785
t.column "latlon_geo", :st_point, srid: 4326, geographic: true
t.column "default_latlon", :st_point, srid: 0, default: "POINT(0.0 0.0)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have these ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these were copied from create_model below, happy to remove them if you think it's necessary.

@sql_type_metadata = sql_type_metadata
@geographic = !!(sql_type_metadata.sql_type =~ /geography\(/i)
if spatial
if sql_type_metadata.type == :enum
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we should not be there if we are handling enums. Otherwise this also means that sql_type_metadata is set for every column, spatial or not.

I believe we should verify how the step before that one is working to make sure this is the correct place (e.g. who is initialising this)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afaict this is by design.

this is initialized from #new_column_from_field which overrides the rails implementation and returns a SpatialColumn (instead of a PostgreSQL::Column) for all columns.

i'm not sure what would happen if some fields were one type and some were another but it seems out of scope for this pr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

geometric_type false positive when enum name matches pattern

2 participants