Bug report #20739

Qgis3 imports DATE type colum in oracle Database as QDate, losing hh:mm:ss

Added by Friedrich Meckel almost 6 years ago. Updated over 5 years ago.

Status:Open
Priority:Normal
Assignee:Jürgen Fischer
Category:Data Provider/Oracle
Affected QGIS version:3.4.2 Regression?:No
Operating System:Windows Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:28559

Description

Hello Community,

I am at the moment working on a lift for an Qgis2 plugin to work with Qgis3.

The plugin specifies a QgsDataSourceUri and uses it in an QgsVectorLayer.
In the specific table, laying in an Oracle database, there is a column which is not named 'date' but a german name.
The type of that column is DATE type, therefore containing year, month, day, hour, minute and second.

In Qgis2.10 this column was automaitcally converted to an QDateTime object by the constructor.
In Qgis3.4.2 however this column is converted to QDate, losing the hours, minutes and seconds by that.

In the documentation I cannot find any explanation on how to specify the way a column is converted to prevent that Dataloss.
Therefore I create this ticket as a bug.

History

#1 Updated by Friedrich Meckel almost 6 years ago

The loading procedure looks like this:

def fetch_layer(self):        
uri = QgsDataSourceURI()
uri.setConnection(self.host, self.port, self.db_name, self.usr, self.pswd)
uri.setDataSource(self.schema, self.table, "SHAPE", "username=\'{}\'".format(self.usr))
layer = QgsVectorLayer(uri.uri(), self.layername, "oracle")
print(f"This should not be QDate : {type(next(layer.getFeatures()).attribute(self.date_attr))}")

#2 Updated by Enrico Fiore over 5 years ago

Hi, I have the same problem.
This is a big issue because is not possible save editing, because this cause QGIS crash when I try to save changes. I thing because data types are in contrast and Oracle doesn't accept Date without hh:ss:mm.

Affected QGIS version:3.4.6, running in windows 7

Also available in: Atom PDF