From fc14ccd2d5a516ded8cd6ffc2f5adba4f1026f67 Mon Sep 17 00:00:00 2001 From: pieterlukasse Date: Tue, 21 Jan 2025 21:10:40 +0100 Subject: [PATCH] test: using global temp table --- models/helper.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/helper.go b/models/helper.go index cee242d..f854939 100644 --- a/models/helper.go +++ b/models/helper.go @@ -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). @@ -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,