-
-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -210,6 +210,18 @@ def test_multi_polygon_column | |
| assert_equal wkt, rec.m_poly.to_s | ||
| end | ||
|
|
||
| def test_spatial_column_matching_enum | ||
| SpatialModel.lease_connection.create_enum(:point_type, ["point", "line_string", "polygon"]) | ||
| SpatialModel.lease_connection.create_table(:spatial_models, force: true) do |t| | ||
|
Comment on lines
+214
to
+215
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it properly cleanup afterwards ? If so, how ?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)" | ||
|
Comment on lines
+216
to
+218
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we have these ?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these were copied from |
||
| t.enum "point_type", enum_type: :point_type | ||
| end | ||
| SpatialModel.reset_column_information | ||
| point_type = SpatialModel.columns.find { |c| c.name == "point_type" } | ||
| assert_nil point_type.geometric_type | ||
| end | ||
| private | ||
|
|
||
| def create_model | ||
|
|
||
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 aPostgreSQL::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.