Skip to content

Commit

Permalink
feat: remove confusing code; test without dryrun
Browse files Browse the repository at this point in the history
  • Loading branch information
pieterlukasse committed Jan 22, 2025
1 parent efd202e commit 6b02d5c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions models/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,19 @@ func QueryFilterByConceptDefHelper(query *gorm.DB, sourceId int, filterConceptDe
if filterConceptDef.Transformation != "" {
// simple filterConceptDef with just the concept id
simpleFilterConceptDef := utils.CustomConceptVariableDef{ConceptId: filterConceptDef.ConceptId}
resultingQuery := QueryFilterByConceptDefHelper2(query, sourceId, simpleFilterConceptDef,
query := QueryFilterByConceptDefHelper2(query, sourceId, simpleFilterConceptDef,
omopDataSource, "", personIdFieldForObservationJoin, "observation_continuous", observationTableAlias+"_a")
tmpTransformedTable, err := TransformDataIntoTempTable(omopDataSource, resultingQuery, filterConceptDef)
tmpTransformedTable, err := TransformDataIntoTempTable(omopDataSource, query, filterConceptDef)
// TODO - the resulting query should actually be Select * from temptable.... as this collapses all underlying queries. TODO2 - ensure the transform method also filters....
resultingQuery = QueryFilterByConceptDefHelper2(query, sourceId, filterConceptDef, //TODO - turn around
omopDataSource, "", personIdFieldForObservationJoin, tmpTransformedTable, observationTableAlias+"_b")
return resultingQuery, observationTableAlias + "_b", err
query = QueryFilterByConceptDefHelper2(query, sourceId, filterConceptDef, //TODO - turn around
omopDataSource, "", personIdFieldForObservationJoin, tmpTransformedTable, observationTableAlias+"_b") //PA the temp table seems to be created in one session....and not visible in another session....hm...in reality, that can't be the case, because the one created in data studio is visible to the gorm....it is basically gorm NOT creating temp tables...not sure why not....
return query, observationTableAlias + "_b", err

} else {
// simple filterConceptDef with no transformation
resultingQuery := QueryFilterByConceptDefHelper2(query, sourceId, filterConceptDef,
query := QueryFilterByConceptDefHelper2(query, sourceId, filterConceptDef,
omopDataSource, "", personIdFieldForObservationJoin, "observation_continuous", observationTableAlias)
return resultingQuery, "", nil
return query, "", nil
}
}

Expand Down
4 changes: 2 additions & 2 deletions utils/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ func ToSQL2(query *gorm.DB) string {

func ToSQL(query *gorm.DB) string {
// Clone the query object to avoid altering the original
tempQuery := query.Session(&gorm.Session{DryRun: true})
sql := tempQuery.ToSQL(func(tx *gorm.DB) *gorm.DB {
//tempQuery := query.Session(&gorm.Session{DryRun: true})
sql := query.ToSQL(func(tx *gorm.DB) *gorm.DB {
return tx.Find([]interface{}{})
})
return sql
Expand Down

0 comments on commit 6b02d5c

Please sign in to comment.