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

Be able to set null for date input #5777

Closed
locopati opened this issue Apr 13, 2020 · 15 comments · Fixed by #7801
Closed

Be able to set null for date input #5777

locopati opened this issue Apr 13, 2020 · 15 comments · Fixed by #7801
Labels
good first issue Good for newcomers issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: core:strapi Source is core/strapi package status: confirmed Confirmed by a Strapi Team member or multiple community members

Comments

@locopati
Copy link

locopati commented Apr 13, 2020

Describe the bug
I want to clear the date that was set on a field

Steps to reproduce the behavior

  1. Create a type with a date field that is not required
  2. Create an instance of the type with a value in the date field and save it
  3. Edit the instance and clear the date field
  4. It cannot be cleared
  5. Make a GraphQL request to clear the field
  6. The request errors

Expected behavior
You can clear the field in the UI
The GraphQL mutation works

Code snippets

mutation UnsetDate($id: ID!) {
  updateYourType(input:{
    where:{
      id: $id
    },
    data: {
      date_field: null
    }
  }) {
    your_type { 
      id
      date_field
    }
  }
}

This returns "message": "Expected type Date, found \"\"; Date cannot represent an invalid date-string ."

System

  • Node.js version: 13.7
  • Yarn version: 1.22
  • Strapi version: 3b19.5
  • Database: Mongo 4.2.5
  • Operating system: Arch Linux 4.19-97

Additional context
Add any other context about the problem here.

@derrickmehaffy
Copy link
Member

Node.js version: 13.7

You are on an unsupported node version, please test on node 12/10.

@lauriejim lauriejim added severity: low If the issue only affects a very niche base of users and an easily implemented workaround can solve severity: medium If it breaks the basic use of the product but can be worked around source: core:strapi Source is core/strapi package status: confirmed Confirmed by a Strapi Team member or multiple community members issue: bug Issue reporting a bug and removed severity: low If the issue only affects a very niche base of users and an easily implemented workaround can solve labels Apr 16, 2020
@lauriejim
Copy link
Contributor

Thank you @locopati for reporting this issue.
This is due to the format validation. Can you please investigate it and submit a PR to allow null
Thank you.

@lauriejim lauriejim added the good first issue Good for newcomers label Apr 16, 2020
@lauriejim lauriejim changed the title Cannot unset date field Be able to set null for date input Apr 16, 2020
@richardgrey
Copy link
Contributor

richardgrey commented May 15, 2020

I think this works now, so the issue could be closed. At least I was not able to reproduce it.

@lauriejim
Copy link
Contributor

This error still exist with MongDB.

@weidox
Copy link

weidox commented Aug 26, 2020

Just encountered same issue, don't know if that's DB related though we're using MongoDB. Trying to unset date field via admin UI, finding no way.

@luisjuniorj
Copy link

This error still exist with PostgreSQL.

@arturaum
Copy link

This error still exist with PostgreSQL.

Any changes?

@lauriejim
Copy link
Contributor

This issue has been mentioned on Strapi Community. There might be relevant details there:

https://forum.strapi.io/t/new-release-strapi-v3-1-7/256/1

@miniskylab
Copy link

Ran into this issue today.

  • Node: 12.18.3
  • Strapi: 3.2.4
  • Database: SQLite
  • OS: Windows 10 Pro

@smoothdvd
Copy link
Contributor

This issue will be fired when you POST formData.

Content type has a non-required field, which type is 'date'.

Error: Invalid format, expected an ISO compatible date
    at parseDate (/Users/alexgao/Dev/find-missing-people/node_modules/strapi-utils/lib/parse-type.js:37:11)
    at parseType (/Users/alexgao/Dev/find-missing-people/node_modules/strapi-utils/lib/parse-type.js:89:14)
    at /Users/alexgao/Dev/find-missing-people/node_modules/strapi-connector-bookshelf/lib/parser.js:12:14
    at /Users/alexgao/Dev/find-missing-people/node_modules/strapi-connector-bookshelf/lib/mount-models.js:463:25
    at Array.map (<anonymous>)
    at mapper (/Users/alexgao/Dev/find-missing-people/node_modules/strapi-connector-bookshelf/lib/mount-models.js:460:29)
    at Child.<anonymous> (/Users/alexgao/Dev/find-missing-people/node_modules/strapi-connector-bookshelf/lib/mount-models.js:619:63)
    at /Users/alexgao/Dev/find-missing-people/node_modules/bookshelf/lib/base/events.js:101:64
From previous event:
    at Child.triggerThen (/Users/alexgao/Dev/find-missing-people/node_modules/bookshelf/lib/base/events.js:101:20)
    at Child.<anonymous> (/Users/alexgao/Dev/find-missing-people/node_modules/bookshelf/lib/model.js:1152:23)
    at processImmediate (internal/timers.js:461:21)
From previous event:
    at Child.<anonymous> (/Users/alexgao/Dev/find-missing-people/node_modules/bookshelf/lib/model.js:1060:10)
From previous event:
    at runCreate (/Users/alexgao/Dev/find-missing-people/node_modules/strapi-connector-bookshelf/lib/queries.js:113:45)
    at /Users/alexgao/Dev/find-missing-people/node_modules/strapi-connector-bookshelf/lib/queries.js:53:34
    at /Users/alexgao/Dev/find-missing-people/node_modules/knex/lib/transaction.js:183:22
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
[2021-05-13T06:59:20.415Z] debug POST /missing-person-notices (42 ms) 500

@MuizU
Copy link

MuizU commented Jul 8, 2022

Did anyone find a workaround in postresql?

@crazyfree
Copy link

today I got same problem.
There is existing data in the database for exam delivery_date = 2023-10-06 00:00:00.000000.
I use API to set it to null so I do set delivery_date = null.
All other fields get updated but delivery_date stay unchanged

@mootensai
Copy link

I think this issue should still opened because we still couldn't set date input to null by null value

@luisjuniorj
Copy link

luisjuniorj commented Oct 6, 2023 via email

@amh092
Copy link

amh092 commented May 4, 2024

Im facing the same issue has anybody solved it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: core:strapi Source is core/strapi package status: confirmed Confirmed by a Strapi Team member or multiple community members
Projects
None yet
Development

Successfully merging a pull request may close this issue.