<div dir="ltr"><div>Hi all,</div><div><br></div><div>I've opened issue <a href="http://hub.qgis.org/issues/10523">http://hub.qgis.org/issues/10523</a> proposing also a solution.</div><div><br></div><div class="gmail_extra">

May someone confirm this bug and have a look at the proposed solution?</div><div class="gmail_extra"><br></div><div class="gmail_extra">Best regards,</div><div class="gmail_extra"><br></div><div class="gmail_extra">Gabriele Monfardini</div>

<div class="gmail_extra"><br></div><div class="gmail_extra"><br>
<br><br><div class="gmail_quote">On Thu, Jun 5, 2014 at 11:11 AM, Gabriele Monfardini <span dir="ltr"><<a href="mailto:gabrimonfa@gmail.com" target="_blank">gabrimonfa@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr">Hi all,
<div><br></div><div>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.</div><div>


<br></div><div>All styles have useasdefault set to false (these styles only makes sense within some projects, should not be used as default styles).</div><div><br></div><div>When I open the layer without any project, one of the styles is applied, in particular the one with update_time more recent.</div>


<div><br></div><div>The exact query that finds the default style seems to be</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>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</div>


<div><br></div></blockquote><div><br></div>In my opinion rows with useasdefault set to false should be completely filtered out by the query.<div><br></div><div>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.</div>


<div><br></div><div>Thus I propose to change the query in</div><div><br></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>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<br>


</div><div><br></div></blockquote>Would you like me to open a bug?</div><div><br></div><div>Regards,</div><div><br></div><div>Gabriele Monfardini</div><div><br></div></div>
</blockquote></div><br></div></div>