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:
parent
26cc46c7b0
commit
77cbb3c212
|
@ -196,13 +196,13 @@ func newBookingForm(ctx context.Context, company *auth.Company, conn *database.C
|
||||||
rows, err := conn.Query(ctx, `
|
rows, err := conn.Query(ctx, `
|
||||||
select 'campsite_type_option_' || option.campsite_type_option_id
|
select 'campsite_type_option_' || option.campsite_type_option_id
|
||||||
, slug
|
, slug
|
||||||
, coalesce(option.name, i18n.name) as l10_name
|
, coalesce(i18n.name, option.name) as l10_name
|
||||||
, lower(range)::text
|
, lower(range)::text
|
||||||
, lower(range)
|
, lower(range)
|
||||||
, upper(range)
|
, upper(range)
|
||||||
from campsite_type_option as option
|
from campsite_type_option as option
|
||||||
join campsite_type using (campsite_type_id)
|
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
|
where company_id = $2
|
||||||
order by option.position, l10_name
|
order by option.position, l10_name
|
||||||
`, l.Language, company.ID)
|
`, l.Language, company.ID)
|
||||||
|
|
Loading…
Reference in New Issue