Skip to content

Commit

Permalink
test: using global temp table
Browse files Browse the repository at this point in the history
  • Loading branch information
pieterlukasse committed Jan 21, 2025
1 parent 3d11a93 commit fc14ccd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions models/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func QueryFilterByConceptDefHelper2(query *gorm.DB, sourceId int, filterConceptD
log.Printf("Adding extra INNER JOIN with alias %s", observationTableAlias)
aliasedObservationDataSource := omopDataSource.Schema + "." + observationDataSource + " as " + observationTableAlias + omopDataSource.GetViewDirective()
// for temp table, the alias is slightly different:
if strings.HasPrefix(observationDataSource, "tmp_") || strings.HasPrefix(observationDataSource, "#tmp_") {
if strings.HasPrefix(observationDataSource, "tmp_") || strings.HasPrefix(observationDataSource, "##tmp_") {
aliasedObservationDataSource = observationDataSource + " as " + observationTableAlias
}
query = query.Joins("INNER JOIN "+aliasedObservationDataSource+" ON "+observationTableAlias+".person_id = "+personIdFieldForObservationJoin).
Expand Down Expand Up @@ -204,7 +204,7 @@ func TempTableSQLAndFinalName(omopDataSource *utils.DbAndSchema, tempTableName s
tempTableName, selectStatement, fromSQL, extraWhereSQL,
)
if omopDataSource.Vendor == "sqlserver" {
finalTempTableName = "#" + tempTableName // Local temp table for MSSQL
finalTempTableName = "##" + tempTableName // Global temp table for MSSQL
tempTableSQL = fmt.Sprintf(
"SELECT %s INTO %s FROM (%s) T WHERE %s",
selectStatement, finalTempTableName, fromSQL, extraWhereSQL,
Expand Down

0 comments on commit fc14ccd

Please sign in to comment.