Fix SQL to get list of all accommodation options for booking form

I was using the wrong fields to join with i18n, and had the parameters
to coalesce function call reversed.
This commit is contained in:
jordi fita mas 2024-01-22 03:24:53 +01:00
parent 26cc46c7b0
commit 77cbb3c212
1 changed files with 2 additions and 2 deletions

View File

@ -196,13 +196,13 @@ func newBookingForm(ctx context.Context, company *auth.Company, conn *database.C
rows, err := conn.Query(ctx, `
select 'campsite_type_option_' || option.campsite_type_option_id
, slug
, coalesce(option.name, i18n.name) as l10_name
, coalesce(i18n.name, option.name) as l10_name
, lower(range)::text
, lower(range)
, upper(range)
from campsite_type_option as option
join campsite_type using (campsite_type_id)
left join campsite_type_option_i18n as i18n on i18n.campsite_type_option_id = option.campsite_type_id and i18n.lang_tag = $1
left join campsite_type_option_i18n as i18n on i18n.campsite_type_option_id = option.campsite_type_option_id and i18n.lang_tag = $1
where company_id = $2
order by option.position, l10_name
`, l.Language, company.ID)