server: fix mysql error when list Shared templates for projects#8020
Conversation
without this PR
```
(localcloud) 🐱 > list templates listall=true templatefilter=shared showunique=true projectid=-1
🙈 Error: (HTTP 530, error code 4250) DB Exception on: com.mysql.cj.jdbc.ClientPreparedStatement: SELECT DISTINCT(template_view.id) FROM template_view WHERE template_view.account_type = 5 AND template_view.lp_account_id IN ) AND template_view.hypervisor_type='KVM' AND template_view.format != 'ISO' AND template_view.template_state IN ('Active','UploadAbandoned','UploadError','NotUploaded','UploadInProgress') AND template_view.removed IS NULL ORDER BY template_view.sort_key ASC , template_view.temp_zone_pair ASC LIMIT 0, 500
```
with this PR, it returns empty result
|
@blueorangutan package |
|
@weizhouapache a [SF] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
| if (permittedAccounts.isEmpty()) { | ||
| return new Pair<>(new ArrayList<>(), 0); | ||
| } | ||
| sc.addAnd("sharedAccountId", SearchCriteria.Op.IN, permittedAccountIds.toArray()); |
There was a problem hiding this comment.
seems a bit like a hack on a hack, shouldn´t this be handled by the SearchCriteria<>.addAnd()?
There was a problem hiding this comment.
@DaanHoogland
no idea. I just verified this change fixes the issue.
if you find another solution, it would be better, I will close this PR in that case.
There was a problem hiding this comment.
I researched a little and the handling of an empty set is going to be just as ugly. Let's go with this.
|
Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 7168 |
Codecov Report
@@ Coverage Diff @@
## 4.18 #8020 +/- ##
============================================
- Coverage 13.06% 13.06% -0.01%
Complexity 9106 9106
============================================
Files 2720 2720
Lines 257506 257508 +2
Branches 40149 40150 +1
============================================
Hits 33649 33649
- Misses 219627 219629 +2
Partials 4230 4230
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
|
@blueorangutan test |
|
@DaanHoogland a [SF] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-7792)
|
|
tested; as reported: after merging |
* 4.18: server: fix mysql error when list Shared templates for project (#8020)

Description
This fixes the mysql error when list Shared templates for projects
without this PR
with this PR, it returns empty result
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?