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

TOML dates no longer support equality tests against now #9979

Closed
aaronpowell opened this issue Jun 6, 2022 · 3 comments · Fixed by #9981
Closed

TOML dates no longer support equality tests against now #9979

aaronpowell opened this issue Jun 6, 2022 · 3 comments · Fixed by #9981
Assignees
Milestone

Comments

@aaronpowell
Copy link

I recently upgraded from an old version (in the 0.50's I think) and have noticed a problem with a template that does a filter against some data that's in TOML using dates.

I have items such as the following:

{ date = 2022-06-20, name = "End to end GraphQL (workshop)", link = "https://ndcmelbourne.com/agenda/end-to-end-graphql/daba56ef9e98", event = "NDC Melbourne 2022" },

And use it in a template like so:

{{ if .Site.Params.speaking.enable }} {{ with .Site.Params.speaking }}
<section id="speaking" class="container">
    <div>
        <h2>{{ .title }}</h2>
        {{ $talks := where .talks "date" ">" now }} {{ if eq (len $talks) 0 }}
        <p>{{ .noTalks }}</p>
        {{ else }}
        <ul class="talk-list">
            {{ range sort $talks "date" "asc" }}
            <li>
                {{ partial "talk" . }}
            </li>
            {{ end }}
        </ul>
        {{ end }}
    </div>
    <div>
        <p>{{ .content }}</p>
        <h3>
            <a href="/talks/" title="Available Talks">My Available Talks</a>
        </h3>
    </div>
</section>
{{ end }} {{ end }}

Upon upgrading to the latest version, the where condition no longer works, I'm assuming because the two types (the TOML date and now) can no longer be compared.

Repo containing the full code is here: https://github.com/aaronpowell/aaronpowell.github.io

Relevant files are:

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.100.1-0afb4866e345d31cbbcbab4349e43f1d36122806+extended linux/amd64 BuildDate=2022-06-01T10:11:48Z VendorInfo=gohugoio

Does this issue reproduce with the latest release?

Yes.

@bep bep removed the NeedsTriage label Jun 6, 2022
@bep bep self-assigned this Jun 6, 2022
@bep bep added this to the v0.100.2 milestone Jun 6, 2022
@bep
Copy link
Member

bep commented Jun 6, 2022

We have a similar issue in #9949 -- which is harder to fix (but that one has a good workaround).

This one, though, is fixable. Thanks for the report and sorry about the site breakage.

bep added a commit to bep/hugo that referenced this issue Jun 6, 2022
Note that this has only been a problem with "raw dates" in TOML files in /data and similar. The predefined front matter
dates `.Date` etc. are converted to a Go Time and has worked fine even after upgrading to v2 of the go-toml lib.

Fixes gohugoio#9979
bep added a commit to bep/hugo that referenced this issue Jun 6, 2022
Note that this has only been a problem with "raw dates" in TOML files in /data and similar. The predefined front matter
dates `.Date` etc. are converted to a Go Time and has worked fine even after upgrading to v2 of the go-toml lib.

Fixes gohugoio#9979
bep added a commit to bep/hugo that referenced this issue Jun 6, 2022
Note that this has only been a problem with "raw dates" in TOML files in /data and similar. The predefined front matter
dates `.Date` etc. are converted to a Go Time and has worked fine even after upgrading to v2 of the go-toml lib.

Fixes gohugoio#9979
bep added a commit to bep/hugo that referenced this issue Jun 6, 2022
Note that this has only been a problem with "raw dates" in TOML files in /data and similar. The predefined front matter
dates `.Date` etc. are converted to a Go Time and has worked fine even after upgrading to v2 of the go-toml lib.

Fixes gohugoio#9979
Updates gohugoio#8895
@aaronpowell
Copy link
Author

We have a similar issue in #9949 -- which is harder to fix (but that one has a good workaround).

This one, though, is fixable. Thanks for the report and sorry about the site breakage.

No worries about the breakage, just my blog so it's not the end of the world 😝

I had seen #9949 and thought they might be related, but it was different enough to raise seperately.

bep added a commit to bep/hugo that referenced this issue Jun 7, 2022
Note that this has only been a problem with "raw dates" in TOML files in /data and similar. The predefined front matter
dates `.Date` etc. are converted to a Go Time and has worked fine even after upgrading to v2 of the go-toml lib.

Fixes gohugoio#9979
@bep bep closed this as completed in #9981 Jun 7, 2022
bep added a commit that referenced this issue Jun 7, 2022
Note that this has only been a problem with "raw dates" in TOML files in /data and similar. The predefined front matter
dates `.Date` etc. are converted to a Go Time and has worked fine even after upgrading to v2 of the go-toml lib.

Fixes #9979
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants