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

In sqllite Min of date return integer type - for other dbs return date type #150

Closed
gowthamrao opened this issue Jun 23, 2021 · 5 comments
Closed

Comments

@gowthamrao
Copy link
Member

Reproducible code

library(Eunomia)
connectionDetails <- Eunomia::getEunomiaConnectionDetails()
connection <- DatabaseConnector::connect(connectionDetails = connectionDetails)
sql <- "select min(DATEFROMPARTS(2021, 1, 1));"
DatabaseConnector::renderTranslateQuerySql(connection = connection, sql = sql)

@schuemie
Copy link
Member

Hmmm, DatabaseConnector should have handled that correctly. There's an easy fix I can make to DatabaseConnector, but we could also decide to change Eunomia to use SQLite's extended types, so it supports dates without DatabaseConnector workarounds.

@gowthamrao
Copy link
Member Author

Using extended types - is that a change in Eunomia package. If yes, then i think we should do the change in Eunomia package (which would be simpler)

Other than testing - i dont think sqllite is used for real CDM (?) i.e. are we supporting sqlite for any reason other than testing?

@schuemie
Copy link
Member

Eunomia is used for testing and for examples (e.g. exercises in the Book of OHDSI)

@schuemie
Copy link
Member

OHDSI/Eunomia#12

@schuemie
Copy link
Member

This issue has been fixed, but does require the upcoming version of SqlRender (1.8.0) as well. Note that the variable name must end with 'date' for DatabaseConnector to convert the field to Date:

library(Eunomia)
connectionDetails <- Eunomia::getEunomiaConnectionDetails()
connection <- DatabaseConnector::connect(connectionDetails = connectionDetails)
sql <- "select min(DATEFROMPARTS(2021, 1, 1)) AS my_date;"
DatabaseConnector::renderTranslateQuerySql(connection = connection, sql = sql)
#     MY_DATE
# 1 2021-01-01

@schuemie schuemie closed this as completed Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants