Bug report #9241

QgsVectorDataProvider.minimumValue() and maximumValue() don't work for Date fields

Added by Anita Graser over 10 years ago. Updated almost 10 years ago.

Status:Closed
Priority:Normal
Assignee:Matthias Kuhn
Category:Data Provider/OGR
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

Description

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

To reproduce:

l=iface.activeLayer()
p=l.dataProvider()
idx=p.fieldNameIndex("DATE")
p.minimumValue(idx).toString()
p.maximumValue(idx).toString()

Related issues

Related to QGIS Application - Bug report #10165: Cannot use "less than"/"greater than" operators on date f... Closed 2014-05-03

History

#1 Updated by Matthias Kuhn over 10 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:
$ (unknown)
$ MAX_DATE: Date (10.0)
$ OGRFeature(test2):0
$ MAX_DATE (Date) = (null)

Please open a bug report there

#3 Updated by Anita Graser over 10 years ago

Should I close the ticket here or wait until the new OGR version is released and included in QGIS downloads?

#4 Updated by Matthias Kuhn over 10 years ago

I guess we have the same kind of bug in the generic fallback code as well, so let's keep it open until we are sure it is fixed there as well.

#5 Updated by Anita Graser over 10 years ago

The fix has been implemented upstream: http://trac.osgeo.org/gdal/ticket/5333#comment:2

#6 Updated by Jürgen Fischer about 10 years ago

  • Resolution set to up/downstream

#7 Updated by Anita Graser about 10 years ago

  • Assignee set to Matthias Kuhn

@Matthias: The OGR side seems to be fixed. Can you have a look at our own code? Or do you know whom to ask? Will QGIS 2.2 use the fixed OGR version?

#8 Updated by Matthias Kuhn about 10 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:

  • MSSQL
  • OGR
  • Postgres
  • Spatialite
  • SQLAnywhere
  • Oracle

#9 Updated by Anita Graser almost 10 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[3] error 1: Type mismatch or improper type of arguments to < operator.

... guess that should be a new ticket?

#10 Updated by Jürgen Fischer almost 10 years ago

  • Status changed from Open to Closed

#11 Updated by Anita Graser almost 10 years ago

follow-up issue: #10165

Also available in: Atom PDF