Number comparison in WHERE clause

Hi there,

I’m not sure if this is a bug or if there is any reason for that.

Lets assume having content pages with front-matter like this:

title = "Cool Brand"
brand_id = 1234
brand_id_as_string = "1234"
section = "brands"

When I now try to get this page I use:

{{ $selected_brands := (slice 1234 4442 3398 ) }}
{{ $brands := where (where .Site.Pages "Section" "brands") "Params.brand_id" "in" $selected_brands }}

Unfortunately this doesn’t work, while using a front-matter parameter as string works in the comarison:

{{ $selected_brands := (slice 1234 4442 3398 ) }}
{{ $brands := where (where .Site.Pages "Section" "brands") "Params.brand_id_as_string" "in" $selected_brands }}

I also tested this with eq but had the same bad luck.

Any hints? Currently I am using JSON in front-matter directly generated by server so therefore numbers will stay numbers and its a bit hacky to convert numbers into strings after the conversion. So I’m not sure if this is intended to act like that, or if I’m doing something wrong.

Regards

I stumbled on a similar problem, looked for similar threads and found your unanswered question.

I found a workaround with int if you’re interested. here