-
-
Notifications
You must be signed in to change notification settings - Fork 377
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
Allow promoting column as an id in ST_AsGeoJsonRow #749
Conversation
I have not opened trac issue since I have not received mantra for osgeo account yet. Tests pass ( |
2c1c282
to
db150bf
Compare
db150bf
to
93203c9
Compare
You should have received the mantra by now, could you file that ticket and reference it here in comments and in commit log please ? The mail was sent to you on |
93203c9
to
5100b65
Compare
I have opened https://trac.osgeo.org/postgis/ticket/5596 |
5100b65
to
b9dd4ca
Compare
@pramsey have any issues with this pull request? |
@strk at a glance, most of this is in order, @jtojnar did a good job of updating the documentation and adding tests. My only concern is I don't think our plumbing is set up to handle a change in args of function correct? So adding to drop the old function and create a new is required. I'm going to shove this thru one of our upgrade testers to see if it breaks. I suspect it will. |
As I feared it fails the upgrade test - https://woodie.osgeo.org/repos/30/pipeline/1540/20 @jtojnar this will cause some upgrade burdens. There are two approaches to go with this
approach 2) a) overwrite the old signature as you are doing now The benefit of option one is I think it will cause less upgrade pain for folks who are using ST_AsGeoJSON row variant in their views and materialized views, but does cause some extra baggage for us to carry around My vote is for option 2 even though it will cause more pain for folks. |
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.
Needs to add a drop statement here - https://github.com/postgis/postgis/blob/master/postgis/postgis_before_upgrade.sql to drop the old signature or define a whole new function leaving the old signature intact.
Would not the |
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.
Either approach to the new SQL signature is fine with me
b9dd4ca
to
7e7fc61
Compare
Actually, it looks like just adding a new signature is what is currently happening. I tried the following: CREATE OR REPLACE FUNCTION dup(int) RETURNS TABLE(f1 int, f2 text)
AS $$ SELECT $1, CAST($1 AS text) || ' is text' $$
LANGUAGE SQL;
CREATE OR REPLACE FUNCTION dup(int, int=4) RETURNS TABLE(f1 int, f2 text)
AS $$ SELECT $1 + $2, CAST($1 AS text) || ' is text' $$
LANGUAGE SQL;
select dup(1); And got the same error as in the upgrade check:
Pushed the suggested removal. |
I forgot to mention for the new signature, you can't have it have a default. That default needs to be removed otherwise you do get a duplicate. |
A little, but not as much because it doesn't bloat the function base. We still end up with the same number of functions in the end, which as a user, is all I care about. From a developer standpoint I prefer it more, cause I'm always staring at the function definitions sql.in files, and I'm not staring so much at the drop sql file. :) |
I see you went with the drop approach. At a glance all looks in order to me. I'll do one final upgrade check and accept unless @strk has any opinions |
still failing with not unique during upgrade https://woodie.osgeo.org/repos/30/pipeline/1540/20 The postgis_before_drop should have taken care of this. I'm investigating now.
|
As per GeoJSON RFC, the id should go directly to the feature object rather than to properties: > If a Feature has a commonly used identifier, that identifier > SHOULD be included as a member of the Feature object with the name "id" Let’s add an argument that will allow designating a column as an identifier so that people do not have to tediously build the JSON object manually. References #5596
7e7fc61
to
a1654f0
Compare
There is still an issue with our dump restore tests on 3.0, but I'm let this go in since I think the issue might be on our end. I also made some minor adjustments, changing bool to boolean in the postgis.sql.in (I know it was like that when you saw it)., but figure we should make it match with the drop. I also need to do the same for the other functions we have in postgis.sql.in that use the short-hand bool. Added the NEWS item. |
@@ -173,3 +173,9 @@ BEGIN | |||
END; | |||
$$; | |||
|
|||
-- FUNCTION ST_AsGeoJson added `id_column` optional argument in 3.5.0. | |||
SELECT _postgis_drop_function_by_identity |
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.
For the record: by adding a new parameter we actually created a NEW SIGNATURE (rather than changing the identity of an existing signature). So we'd have needed a different function (drop by signature) BUT the simplest way to deal with upgrades is the use a Replaces
comment, like it was done to fix the bug which resulted by this misues of _postgis_drop_function_by_identity, see
https://trac.osgeo.org/postgis/ticket/5623#comment:5
https://git.osgeo.org/gitea/postgis/postgis/commit/a6f4fa8282d3fef7e298f66cb7db96674486f028
As per GeoJSON RFC, the id should go directly to the feature object rather than to properties:
Let’s add an argument that will allow designating a column as an identifier so that people do not have to tediously build the JSON object manually.
References https://trac.osgeo.org/postgis/ticket/5596