Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

auto-detection of postgres primary key field #804

Closed
artemp opened this Issue Oct 11, 2011 · 4 comments

Comments

Projects
None yet
2 participants
Owner

artemp commented Oct 11, 2011

With postgres, a key_field provided by the user is currently necessary for ensuring that the postgis plugins feature.id() is globally unique. When not provided the feature_count is simply incremented for each query and used to populate the feature id value for each feature (so feature id's are not unique across queries).

Ideally we could support auto-detection of primary key so that we can promise, when possible, globally unique feature id's.

Since globally unique primary keys are not needed for normal rendering usage the current behavior (of not requiring a primary key and simply incrementing the feature counter) will be maintained (even though this is unique behavior to postgis.input).

But a new option autodetect_key_field will be added that will trigger the autodetection behavior and then mapnik will throw if no valid primary key can be detected (and if none is supplied).

Owner

artemp commented Oct 11, 2011

[springmeyer] see also #821 for sqlite

springmeyer pushed a commit that referenced this issue Apr 2, 2012

Owner

springmeyer commented Apr 5, 2012

re-opening, there was a flaw in this work that breaks the common and widespread usage of subquery syntax for rendering (where a primary key/id field is rarely used). Basically the problem is that its common for subqueries to be written like table="(select way from planet_osm_line) as t" and if we autodetect osm_id and append it then the final select mapnik forms up will fail because osm_id is not pulled in the subselect.

springmeyer pushed a commit that referenced this issue Apr 5, 2012

postgis: primary key autodetection will now only happen if 'autodetec…
…t_key_field' is set to true - maintains current behavior - refs #804

@springmeyer springmeyer reopened this Apr 5, 2012

Owner

springmeyer commented Apr 5, 2012

b7f714f - rolls back to current behavior whereby no primary key will be autodetected (and added to the final query) unless explicitly requested. closing.

@springmeyer springmeyer closed this Apr 5, 2012

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