Bug report #9241
QgsVectorDataProvider.minimumValue() and maximumValue() don't work for Date fields
|Affected QGIS version:||2.0.1||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||up/downstream|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||17859|
minimumValue(idx).toString() and maximumValue(idx).toString() only return empty strings.
The issue popped up because TimeManager currently does not support Date fields: https://github.com/anitagraser/TimeManager/issues/37
If you need a test dataset try: http://ge.tt/6DBclJh/v/0
l=iface.activeLayer() p=l.dataProvider() idx=p.fieldNameIndex("DATE") p.minimumValue(idx).toString() p.maximumValue(idx).toString()
#1 Updated by Matthias Kuhn over 6 years ago
- Category changed from Data Provider to Data Provider/OGR
This seems to be an upstream OGR issue:
$ ogrinfo /tmp/test/test2.shp -sql "SELECT MAX( 'DATE' ) from test2"
$ INFO: Open of `/tmp/test/test2.shp'
$ using driver `ESRI Shapefile' successful.
$ Layer name: test2
$ Geometry: 3D Point
$ Feature Count: 1
$ Layer SRS WKT:
$ MAX_DATE: Date (10.0)
$ MAX_DATE (Date) = (null)
Please open a bug report there
#8 Updated by Matthias Kuhn over 6 years ago
As soon as you install the updated OGR on your machine, QGIS will make use of it, even if you still run QGIS 2.0. The only platforms where we can control this are OSGeo4W and Mac OS X. Best to ping the responsible people there.
For our side, I think I have a branch somewhere which implements this. But this would need to be tested with a provider which uses the fallback code (i.e. which is NOT in the list below) and I am very tight on time right now... I will check the code I have and upload if it's useful.
Provider side implementations for maximumValue:
#9 Updated by Anita Graser over 6 years ago
Min/max looks fine in master (OSGeo4W) with the new OGR included.
Unfortunately there is still an issue querying date fields: I cannot seem to use < and > operators in queries:
OGR error 1: Type mismatch or improper type of arguments to < operator.
... guess that should be a new ticket?