From 794036487fb80265a905b9eb8221620098324785 Mon Sep 17 00:00:00 2001 From: Alexander Todorov Date: Wed, 2 Feb 2022 11:40:51 +0200 Subject: [PATCH] Convert values to array when updating Version/Build. Fixes #2704. On pages where a single selection can be made tha value is a string, while on pages with multiple selection the value is an array. This causes the API to not return any values b/c the selector product__in="string" doesn't work on Postgres. Making sure that we always pass array as an argument to the ORM selector works on all database backends. --- tcms/static/js/utils.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tcms/static/js/utils.js b/tcms/static/js/utils.js index f6a31e880e..079b8ff584 100644 --- a/tcms/static/js/utils.js +++ b/tcms/static/js/utils.js @@ -51,8 +51,13 @@ function updateVersionSelectFromProduct () { $('#id_version').change() } - const productIds = $('#id_product').val() + let productIds = $('#id_product').val() + if (productIds.length) { + if (!Array.isArray(productIds)) { + productIds = [productIds] + } + jsonRPC('Version.filter', { product__in: productIds }, updateVersionSelectCallback) } else { updateVersionSelectCallback([]) @@ -73,8 +78,12 @@ function updateBuildSelectFromVersion (keepFirst) { $('#id_build').find('option').remove() } - const versionIds = $('#id_version').val() + let versionIds = $('#id_version').val() if (versionIds.length) { + if (!Array.isArray(versionIds)) { + versionIds = [versionIds] + } + jsonRPC('Build.filter', { version__in: versionIds }, updateCallback) } else { updateCallback([])