Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"where" filter doesn't appear to accept integer values in 4.0 #7820

Closed
whicks1 opened this issue Sep 18, 2019 · 4 comments · Fixed by #7821
Closed

"where" filter doesn't appear to accept integer values in 4.0 #7820

whicks1 opened this issue Sep 18, 2019 · 4 comments · Fixed by #7821
Labels
bug frozen-due-to-age has-pull-request Somebody suggested a solution to fix this issue regression
Milestone

Comments

@whicks1
Copy link

whicks1 commented Sep 18, 2019

My Environment

Software Version(s)
Operating System MacOS 10.14.5
jekyll Latest (4.0)
github-pages No

Expected Behaviour

  • when making a template assignment
  • and using a where filter,
  • and value is an integer,

we should return the corresponding assigned object

Current Behavior

Since upgrade from 3.x to 4.0, I no longer return an object if the value is a number. ("where_exp" does work, so does a "where" filter with a string value).

Code Sample

Assume an "orgs" collection, containing hr.md with deptid: 2765 and in some site template I only want to pull data about the HR department:
{%- assign dept = site.orgs | where: "deptid", 2765 | first -%}

{{ dept.other_metadata }} returns relevant data in 3.x, nothing in 4.0.

these would work however:

{%- assign dept = site.orgs | where: "deptid", "hr" | first -%}
if hr.md's id == "hr" instead; success.

{%- assign dept = site.orgs | where_exp: "dept", "dept.deptid == 2765" | first -%}
where_exp with INT; also success.

Maybe this is just a change in the latest liquid, either way might be worth documentation for migrations.

@ashmaroli ashmaroli added this to the 4.1 milestone Sep 18, 2019
@jekyllbot jekyllbot added the has-pull-request Somebody suggested a solution to fix this issue label Sep 19, 2019
@jaredcwhite
Copy link

@whicks1 Thanks for reporting this! I ran into the same issue but hadn't gotten a chance to write up what was going on. (And I ended up switching to using where_exp as a workaround…)

@ashmaroli
Copy link
Member

Sorry for the inconvenience, guys. In case you want to continue using the where filter, you may point your Gemfile to the PR linked above:

gem "jekyll". github: "jekyll/jekyll", ref: "refs/pull/7821/head"

@ashmaroli
Copy link
Member

Hello everyone!
Can someone report back if the current master resolves this issue..?
You can edit your Gemfile to following to test:

gem "jekyll", github: "jekyll/jekyll"

Thanks.

@whicks1
Copy link
Author

whicks1 commented Jan 10, 2020

gem "jekyll", github: "jekyll/jekyll"

worksforme

@jekyll jekyll locked and limited conversation to collaborators Feb 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug frozen-due-to-age has-pull-request Somebody suggested a solution to fix this issue regression
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants