[Qgis-developer] Query layers are bad layers when empty

Olivier Dalang olivier.dalang at gmail.com
Mon Jun 2 08:17:24 PDT 2014


Hi !

I love the "query layer" feature !

But there's something which makes it unusable : as soon as it returns an
empty result set (which is absolutely valid), it is considered as a "bad
layer" upon file opening, and the layer is destroyed.

When working with spatialite, it triggers the "handle bad layers dialog",
which unfortunately is of no help.
When working with postgis, it shortly displays a message in the message
bar, which I sometimes miss, and I also loose my layers.


Here's what I found so far :

- when "filtering" a regular spatialite/postgis layer, if the filter
filters out every feature, the layer is still valid. (works as expected)
- when a query layer returns an empty result set, the layer is considered
bad (unexpected).
- when a query layer returns an non-empty result set, but the query layer
is filtered, the layer is considered bad (unexpected).
- empty views work well, filtered or not (works as expected)

So, views are a kind of workaround, but depending on the needs (for example
if you need to change your query very often), it's not really usable
either, because it's much longer to setup and it pollutes the database.


Does anyone have a workaround for this ? Why does QGIS have to consider
empty query layers as invalid, while they work perfectly well (as long as
you don't reopen the file) ?


I would definitely create a blocker issue for this (there are already
linked issues, see below, but it seems they aren't considered as blockers)
: it leads to loosing query layers very easily (and almost silently for
postgis). It would be great if this could be fixed for 2.4 !

Thanks for reading !

Olivier


PS1 A test setup :
https://www.dropbox.com/sh/6jar5134pvqjbjj/AADx9WoUqh3CAAyKQoMAekXla

PS2 Some related issues on the tracker :
http://hub.qgis.org/issues/7039 (about using message bar for bad layers)
http://hub.qgis.org/issues/9708 (WMS bad layers have similar problems)
http://hub.qgis.org/issues/9743 (Oracle bad layers have similar problems)
http://hub.qgis.org/issues/8718 (feature request which asks for solving
this)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20140602/be4f28e2/attachment-0001.html>


More information about the Qgis-developer mailing list