You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Author Name: Gabriele Monfardini (@gabrimonfa)
Original Redmine Issue: 10523
Redmine category:data_provider/postgis
I have a postgis layer with several styles saved in table public.layer_styles.
All styles have useasdefault set to false (these styles only makes sense within some projects, should not be used as default styles).
Obtained results
When I open the layer without any project, one of the styles is applied, in particular the one with update_time more recent.
Expected results
When I open the layer without any project, no style is applied
Discussion
The exact query that finds the default style is in ~qgis/src/providers/postgres/qgspostgresprovider.cpp, line 3464
QString selectQmlQuery = QString( "SELECT styleQML"
" FROM layer_styles"
" WHERE f_table_catalog=%1"
" AND f_table_schema=%2"
" AND f_table_name=%3"
" AND f_geometry_column=%4"
" ORDER BY CASE WHEN useAsDefault THEN 1 ELSE 2 END"
",update_time DESC LIMIT 1" )
In my opinion rows with useasdefault set to false should be completely filtered out by the query.
If all styles have useasdefault set to false, current query retrieves the most recent style while I think that no rows should be retrieved in this case and a "random color" style be applied.
Thus I propose to change the query to:
QString selectQmlQuery = QString( "SELECT styleQML"
" FROM layer_styles"
" WHERE f_table_catalog=%1"
" AND f_table_schema=%2"
" AND f_table_name=%3"
" AND f_geometry_column=%4"
" WHERE useAsDefault"
" ORDER BY update_time DESC LIMIT 1" )
There are two order criteria - first useDefault, second update_time. So the style with default comes first and the reset is ordered by update_time - that means if there is no style with useDefault the most current non-default style is taken. IMHO that's no bug - although the other behavior also makes sense.
Author Name: Gabriele Monfardini (@gabrimonfa)
Original Redmine Issue: 10523
Redmine category:data_provider/postgis
I have a postgis layer with several styles saved in table public.layer_styles.
All styles have useasdefault set to false (these styles only makes sense within some projects, should not be used as default styles).
Obtained results
When I open the layer without any project, one of the styles is applied, in particular the one with update_time more recent.
Expected results
When I open the layer without any project, no style is applied
Discussion
The exact query that finds the default style is in ~qgis/src/providers/postgres/qgspostgresprovider.cpp, line 3464
In my opinion rows with useasdefault set to false should be completely filtered out by the query.
If all styles have useasdefault set to false, current query retrieves the most recent style while I think that no rows should be retrieved in this case and a "random color" style be applied.
Thus I propose to change the query to:
The text was updated successfully, but these errors were encountered: