Bug report #11843
Oracle provider is not able to handle non-geometric tables correctly
|Affected QGIS version:||2.6.0||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||20060|
it seems that the Oracle provider of QGis is not able to handle non-geometric tables correctly.
Under Python API, I've found that you need to use a QgsFeatureRequest with a flag set to NoGeometry to be able to fetch features.
This is not the default behavior as written in PyQGis cookbook and nor PostGIS or Spatialite ones.
The following code returns no feature on an Oracle non-geographic layer (even with a primary key). Under PostGIS and Spatialite, the code succeeds.
layer = QgsMapLayerRegistry.instance().mapLayersByName('MY_ATTRIBUTE_TABLE') for f in layer.getFeatures(): print f
You have to restrict to a NoGeometry QgsFeatureRequest if you want to fetch features:
layer = QgsMapLayerRegistry.instance().mapLayersByName('MY_ATTRIBUTE_TABLE') for f in layer.getFeatures(QgsFeatureRequest().setFlags(QgsFeatureRequest.NoGeometry)): print f
Furthermore, this bug seems to have a bad impact on the "Select by Expression" dialog: it is impossible to make a selection with this dialog on a non-geographic Oracle table. Whatever you type in the expression builder, the selection is always empty. I suspect that this problem is linked to the above one.
Steps to reproduce:
- Open a a non geographic table under Qgis and select it.
- Open the Select by Expression dialog on the loaded layer.
- Try to build a query selection expression like:
"FIELD1" LIKE '%avalue%'
"ID" = 0
- Clic on select button
- The selection is still empty