Skip to content

Commit

Permalink
Convert values to array when updating Version/Build. Fixes #2704.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
atodorov committed Feb 2, 2022
1 parent 62ff9fe commit 7940364
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tcms/static/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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([])
Expand All @@ -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([])
Expand Down

0 comments on commit 7940364

Please sign in to comment.