-
-
Notifications
You must be signed in to change notification settings - Fork 256
Fix: don't match enum columns as spatial #433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| SpatialModel.lease_connection.create_enum(:point_type, ["point", "line_string", "polygon"]) | ||
| SpatialModel.lease_connection.create_table(:spatial_models, force: true) do |t| |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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?
| 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)" |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
fixes #432