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

Gabriele Monfardini gabrimonfa at gmail.com
Tue Jun 10 07:07:57 PDT 2014


Hi all,

I've opened issue http://hub.qgis.org/issues/10523 proposing also a
solution.

May someone confirm this bug and have a look at the proposed solution?

Best regards,

Gabriele Monfardini




On Thu, Jun 5, 2014 at 11:11 AM, Gabriele Monfardini <gabrimonfa at gmail.com>
wrote:

> 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/20140610/15022cd1/attachment.html>


More information about the Qgis-developer mailing list