qgis / QGIS-Documentation

QGIS Documentation
https://docs.qgis.org/latest
467 stars 692 forks source link

Add field domain management capabilities to browser (Request in QGIS) #7365

Open qgis-bot opened 2 years ago

qgis-bot commented 2 years ago

Request for documentation

From pull request QGIS/qgis#47025 Author: @nyalldawson QGIS version: 3.26 (Feature)

Add field domain management capabilities to browser

PR Description:

This PR adds API to manage field domains to database connections, and exposes this functionality through the QGIS browser panel.

Some notes:

TODO:

Demo showing display of existing domain properties:

Peek 2022-01-27 15-14

Commits tagged with [need-docs] or [FEATURE]

"[feature] Add browser properties page for field and fields items\n\nIn particular, this allows users to easily see what field domain\nmay be attached to particular fields" "[feature] Show \"Set Field Domain\" action when right clicking\na field in the browser for a Geopackage table\n\nAllows users to set the field domain associated with that field"

phidrho commented 2 years ago

Hi @nyalldawson and @DelazJ,

I just wanted to note that for GeoPackages there is an already official extension "Schema" defined by GeoPackage Standard which is targeted to solve same problem ("domains" of data) if I understood correctly. Maybe this GP extension should also be implemented in this feature addition (detection and awareness), since we have defined GP as default data format for QGIS.

Please check for more information: http://www.geopackage.org/spec131/index.html#extension_schema

nyalldawson commented 2 years ago

@phidrho

That's exactly what's in use here

Jeroen-GroeneBij commented 1 year ago

To understand this correctly: adding field domains to the geopackage is a different route then setting a value map and saving the style as default style within the gpkg, but has the same result? Which is a specific field has a value map associated to it.

A difference might be that I have not yet found a way to remove a field domain setting from a field, but it is easy to remove the value map setting within a style.

I have also not found a reference to this field domain functionality in the 3.28 User Guide. The differences and similarities with Styling - Attributes Form should be part of such a reference.

Jeroen-GroeneBij commented 1 year ago

Second question, because I really start to like this feature :)

This feature is added to 3.28. I notice I can't use this in 3.22.16 (the option to add field domains is not there), however gpkg with field domains in use are recognized in 3.22.16. It shows for instance a field with a value map as Widget type in Attribute forms. Version 3.16.16 does not recognize it, the same field has Text Edit as widget type.

Am I correct that version 3.22.12, which has the same release date as 3.28.0 is recognizing field domains and anything earlier then 3.22.12 will not recognize this? Or do all versions of 3.22 recognize this?

nyalldawson commented 1 year ago

@Jeroen-GroeneBij

To understand this correctly: adding field domains to the geopackage is a different route then setting a value map and saving the style as default style within the gpkg, but has the same result? Which is a specific field has a value map associated to it.

Well, it has a similar-ish result :laughing:

The difference is that the field domains are a database level setting, whereas value maps are a qgis-only construct. Field domains are enforced by the database itself, and (should!) apply regardless of which application you are using to view/edit the database.

There's also different types of domains. While a "coded" domain is the equivalent of QGIS value maps, there's also range and "glob" domains (for geopackage only) which apply different constraints on the values acceptable in the associated fields. Again, these are all database level constraints.

Worth noting that this isn't just Geopackage, it's also supported for ESRI File Geodatabases.

This feature is added to 3.28. I notice I can't use this in 3.22.16 (the option to add field domains is not there), however gpkg with field domains in use are recognized in 3.22.16. It shows for instance a field with a value map as Widget type in Attribute forms. Version 3.16.16 does not recognize it, the same field has Text Edit as widget type.

Correct - edit/creation support was added after 3.22, but 3.22 supports reading field domains.

Jeroen-GroeneBij commented 1 year ago

@nyalldawson thanks for the clarifications. To be sure: reading field domains (and thus using them when adding or editing data) is implemented from 3.22.0 onwards, or from a specific point release?