Skip to main content
Released

Postgres writer - Add unique / primary option for index creation

Related products:Integrations
mark2atsafe
  • mark2atsafe
    mark2atsafe

Todo: For the Postgres / PostGIS writers add the option to make an added index unique or primary

Why: Having the ability to have FME create indexes on created tables is great. However many GIS applications need a primary key, or unique index to insure that only one item is updated, or selected with that key. Adding the option to make the index unique saves a manual step in creating an pk or unique index for a table afterward.

6 replies

Forum|alt.badge.img+1
  • January 31, 2019

Isn't this functionality available in FeatureWriter? Set Attribute Definition in User Attributes to manual and you can change the Index value to 'Primary Key.' I presume that is doing what you need? It just worked for me writing into Postgres, anyway.


Forum|alt.badge.img

I would like to let the postgis database create the unique serial primary key for me.

Manually setting the primary key to some (presumably) unique value is perfect when you have a unique value that links back to the original data source. And some other cases. Not so when the sole function of the primary key is to exist, so other applications can use it for sorting, batch-processing N features at a time and so on.

One prime example: Serving WFS through Geoserver on top of a postgis. Geoserver will not complain about it - but QGIS will not be able to use the WFS services if the primary key doesn't exist and is exposed through geoserver.

For this use case, having the database auto increment the primary key is the obvious way to do it. And it would be REALLY nice if the postgis/postgresql writer had this option available.


mark2atsafe
Safer
Forum|alt.badge.img+45

I believe it will do this already as long as you set the field type to serial. From the R+W doc:

serialThis type is used to represent an auto incrementing four-byte integer. The range is 1 to 2147483647. This is similar to specifying an integer column that has default values to be assigned from a sequence generator. It also has a NOT NULL constraint applied to it.

ponceta
Contributor
Forum|alt.badge.img+7
  • Contributor
  • March 26, 2020
This is exactly the actual limitation. FME dynamic workspaces are the future of data flow, but if you have to switch to manual to set your primary key, then you lose all benefits of dynamical data flow in FME.

LizAtSafe
Safer
Forum|alt.badge.img+15
  • Safer
  • April 5, 2025
OpenReleased

LizAtSafe
Safer
Forum|alt.badge.img+15
  • Safer
  • April 5, 2025
This dynamically accessing the primary key is available. See the documentation for more information. https://docs.safe.com/fme/html/FME-Form-Documentation/FME-ReadersWriters/postgres/feature-types-w.htm

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings