Hi all,

in QGIS (trunk updated from git to some days ago, but also in QGIS 2.2 and
2.0) I have seen a strange behaviour opening a postgis layer in with some
saved styles 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).

When I open the layer without any project, one of the styles is applied, in
particular the one with update_time more recent.

The exact query that finds the default style seems to be

SELECT styleQML FROM layer_styles WHERE f_table_catalog='mydb' AND
f_table_schema='myschema' AND f_table_name='mytable' AND
f_geometry_column='the_geom' 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 in

SELECT styleQML FROM layer_styles WHERE f_table_catalog='mydb' AND
f_table_schema='myschema' AND f_table_name='mytable' AND
f_geometry_column='the_geom'  WHERE useAsDefault ORDER BY update_time DESC
LIMIT 1

Would you like me to open a bug?

Regards,

Gabriele Monfardini
_______________________________________________
Qgis-developer mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to