I have a memory layer loaded in the QGIS virtual layer in the data source manager. I am trying to run a very simple query:
select * from layer
While this works for the physical layer, it does not work for the memory layer. They output virtual layer is blank, and I know that my memory layer has attribute data.
Is this simply a bug? I want to keep this a memory layer to reduce the number of steps I need to do to arrive at my final result. Should I resort to another tool or is there a workaround?
EDIT
Also found this quote in this link:
Creating a virtual layer with the layer_ref key allows to directly access already loaded QGIS layers (including memory layers).
Best Answer
The upper section,
embeded layers
, allows listing (and using) layers that are not loaded in QGIS table of content.Using an in-memory layer that is not loaded in QGIS is to be tested. I believe the layer is cleared from memory as soon as it is removed from the table of content.
If you do have the in-memory layer loaded in the table of content, you can simply remove it from the
embeded layers
section, and the query will work. I just reproduced your use case and workaround in 3.4.5