This is an automated email from the ASF dual-hosted git repository.
klesh pushed a commit to branch next
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/next by this push:
new fd6c237d6 fix: scope config query to support postgresql and mysql
(#8306)
fd6c237d6 is described below
commit fd6c237d67afc7e4d9af2882bfb240e0588eeb31
Author: Kostas Petrakis <[email protected]>
AuthorDate: Fri Mar 7 10:14:18 2025 +0100
fix: scope config query to support postgresql and mysql (#8306)
---
backend/helpers/srvhelper/scope_config_service_helper.go | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/backend/helpers/srvhelper/scope_config_service_helper.go
b/backend/helpers/srvhelper/scope_config_service_helper.go
index 7a93492a6..9964f3f92 100644
--- a/backend/helpers/srvhelper/scope_config_service_helper.go
+++ b/backend/helpers/srvhelper/scope_config_service_helper.go
@@ -77,12 +77,17 @@ func (scopeConfigSrv *ScopeConfigSrvHelper[C, S, SC])
GetProjectsByScopeConfig(p
ScopeId string
}
scopeTable := (*s).TableName()
+ // Postgres fails as scope_id is a varchar and theOtherPk can be an
integer in some cases
+ join := fmt.Sprintf("LEFT JOIN %s ON (%s.connection_id =
bps.connection_id AND %s = bps.scope_id)", scopeTable, scopeTable, theOtherPk)
+ if scopeConfigSrv.db.Dialect() == "postgres" {
+ join = fmt.Sprintf("LEFT JOIN %s ON (%s.connection_id =
bps.connection_id AND CAST(%s AS varchar) = bps.scope_id)", scopeTable,
scopeTable, theOtherPk)
+ }
errors.Must(scopeConfigSrv.db.All(
&bpss,
dal.Select(fmt.Sprintf("bp.id AS blueprint_id, bp.project_name,
bps.scope_id, %s.*", scopeTable)),
dal.From("_devlake_blueprint_scopes bps"),
dal.Join("LEFT JOIN _devlake_blueprints bp ON (bp.id =
bps.blueprint_id)"),
- dal.Join(fmt.Sprintf("LEFT JOIN %s ON (%s.connection_id =
bps.connection_id AND cast(%s as varchar) = bps.scope_id)", scopeTable,
scopeTable, theOtherPk)),
+ dal.Join(join),
dal.Where("bps.plugin_name = ? AND bps.connection_id = ?",
pluginName, (*scopeConfig).ScopeConfigConnectionId()),
))
projectScopeMap := make(map[string]*models.ProjectScope)