Liquid where filter bug?

Shopify Partner
3 1 0


I don't know if it's appropriate to post here about this issue, or should I open a github liquid issue. Anyway, I am noticing unexpeced behaviour of liquid 'where' filter in one of my cases. I am trying to filter a metaobjects array, that I get with: shop.metaobjects.<type>.values, but it gives me wrong value in my opinion. The metaobject type is referenced inside collection metafields and assigned to it correctly.
If i do the same thing inside for loop, I can see that filtered array is wrong. Here is the example with 'where' filter:

{% assign data = shop.metaobjects.custom_type.values | where: 'metaobject_value', collection.metafields.custom.custom_type.value.metaobject_value %}

This gives me some value, that I don't expect. It's a single MetaobjectDrop that it doesn't even has a 'metaobject_value' same as 'collection.metafields.custom.custom_type.value.metaobject_value'.

But if I do this:

{% for data in shop.metaobjects.custom_type.values %}		
	{% if data.metaobject_value.value == collection.metafields.custom.custom_type.value.metaobject_value.value %}
		<pre>{{ data.metaobject_value.value.title }}</pre>
	{% endif %}
{% endfor %}

I can see that I get correct title values from metaobjects I am trying to filter. 
What am I trying to say is, that 'where' filter behaves different than this for loop, but it should give me same results. It doesn't even respects argument, as it gives me wrong metaobject which doesn't have the same value of a field as collection.metafield field value, which is referencing this metaobject type.

Replies 0 (0)