Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qgis3 imports DATE type column in oracle Database as QDate, loosing hh:mm:ss #28559

Closed
qgib opened this issue Dec 6, 2018 · 2 comments
Closed
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Data Provider Related to specific vector, raster or mesh data providers

Comments

@qgib
Copy link
Contributor

qgib commented Dec 6, 2018

Author Name: Friedrich Meckel (Friedrich Meckel)
Original Redmine Issue: 20739
Affected QGIS version: 3.4.2
Redmine category:data_provider/oracle
Assignee: Jürgen Fischer


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.

@qgib
Copy link
Contributor Author

qgib commented Dec 6, 2018

Author Name: Friedrich Meckel (Friedrich Meckel)


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))}")

@qgib
Copy link
Contributor Author

qgib commented Apr 9, 2019

Author Name: Enrico Fiore (Enrico Fiore)


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

@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! Data Provider Related to specific vector, raster or mesh data providers labels May 25, 2019
@jef-n jef-n changed the title Qgis3 imports DATE type colum in oracle Database as QDate, losing hh:mm:ss Qgis3 imports DATE type column in oracle Database as QDate, loosing hh:mm:ss May 26, 2019
nyalldawson added a commit to nyalldawson/QGIS that referenced this issue May 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Data Provider Related to specific vector, raster or mesh data providers
Projects
None yet
Development

No branches or pull requests

1 participant