2

QGIS 3.22

I have a layer imported into a geopackage from a DXF file. The geopackage is called roads.gpkg. The layer is called "polylines". "polylines" has an attribute "layer" (the name of the CAD layer the feature was on in the dxf file).

I wish to filter "polylines" to exclude features based on the value of "layer". I am using the Query Builder for the layer. So far I cannot get any expression to work. I have tried using just the WHERE clause, I have also tried using a full SQL statements. So far I have tried each of the following

select * from "polylines" where "layer" <> 'AA - Promap not required'

select * from "polylines" where "layer" = 'AA - Promap not required'

"layer" <> 'AA - Promap not required'    

"layer" = 'AA - Promap not required'

select * from "polylines" 

None of the above expressions work. I include below an example screenshot of my expression as entered into the Query Builder. For all examples I get the error message as depicted in the second screenshot.

enter image description here

enter image description here

Can anyone tell me what I am doing wrong.

EDIT 1

I also tried

"fid"=1

Looking at the log message, the error is as follows:

OGR[3] error 1: failed to prepare SQL: SELECT m."fid", m."geom", m."handle", m."block", m."etype", m."space", m."layer", m."olinetype", m."linetype", m."color", m."ocolor", m."color24", m."transparency", m."lweight", m."linewidth", m."ltscale", m."visible", m."width", m."thickness", m."ext" FROM "polylines" m WHERE "polylines_2587f7a9_d0c4_44e1_9872_290a556d0800"."layer" LIKE 'AA - Promap not required'

EDIT 2 I have uninstalled QGIS 3.22.11 and reinstalled 3.22.16. Initially, this resulted in the where clause filter working as a filter. Now it has stopped working again. Even layers with clauses that were wroking are now reporting the same error.

7
  • Did you already try LIKE?
    – user30184
    Feb 16, 2023 at 14:55
  • Your expression as shown in the picture should work (there aren't really room for error). Did you try to restart QGIS / the whole computer ?
    – J.R
    Feb 16, 2023 at 15:00
  • I wonder where this long table name comes "polylines_2587f7a9_d0c4_44e1_9872_290a556d0800"."layer"
    – user30184
    Feb 16, 2023 at 15:12
  • QGIS allocates unique names to tables. I've also tried using this unique name in the query builder - same result. I'm currently uninstalling 3.22.11 and will reinstall 3.22.16 and try again
    – Oisin
    Feb 16, 2023 at 15:27
  • So I uninstalled 3.22.11 and reinstalled 3.22.16. That resolved issues for a few minutes. Now the same error is occurring!
    – Oisin
    Feb 16, 2023 at 15:51

1 Answer 1

0

I have uninstalled QGIS 3.22.11 and re-installed 3.22.16.

In 3.22.16 the error occurs when the layer is editable, regardless of whether changes have been committed (saved) or not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.