[Qgis-developer] Is useasdefault column in public.layerstyles correctly handled when retrieving default style?

Gabriele Monfardini gabrimonfa at gmail.com
Thu Jun 5 02:11:06 PDT 2014


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20140605/88afd933/attachment.html>


More information about the Qgis-developer mailing list