Skip to content

Commit

Permalink
fix: workaround for mysql 42000 error (Unsupported subquery syntax)
Browse files Browse the repository at this point in the history
the optimized query is introduced in 9856df7

Signed-off-by: Xiaofan Hu <[email protected]>
  • Loading branch information
bom-d-van committed Sep 8, 2024
1 parent 9856df7 commit b766093
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions persist/sqldb/workflow_archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,17 @@ func (r *workflowArchive) ListWorkflows(options sutils.ListOptions) (wfv1.Workfl
return nil, err
}

// workaround for mysql 42000 error (Unsupported subquery syntax):
//
// Error 1235 (42000): This version of MySQL doesn't yet support 'LIMIT \u0026 IN/ALL/ANY/SOME subquery'
//
// more context:
// * https://dev.mysql.com/doc/refman/8.0/en/subquery-errors.html
// * https://dev.to/gkoniaris/limit-mysql-subquery-results-inside-a-where-in-clause-using-laravel-s-eloquent-orm-26en
if r.dbType == MySQL {
subSelector = r.session.SQL().Select(db.Raw("*")).From(subSelector).As("x")
}

selector := r.session.SQL().Select(selectQuery).From(archiveTableName).Where(
r.clusterManagedNamespaceAndInstanceID().And(db.Cond{"uid IN": subSelector}),
)
Expand Down

0 comments on commit b766093

Please sign in to comment.