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

Dates saved to offline Entity properties have the wrong format when used in XPath expressions #6510

Closed
lognaturel opened this issue Nov 14, 2024 · 9 comments · Fixed by #6514
Assignees
Labels

Comments

@lognaturel
Copy link
Member

lognaturel commented Nov 14, 2024

ODK Collect version

v2024.1.0 beta 8

Problem description

When an offline update is made to an Entity and this update represents a date, the date is converted to DD/MM/YY HH:MM format instead of remaining in ISO 8601 format. This means that any expressions trying to use that date crashes. This is a local-only issue: once the Entity is updated on the server and synced back to the device, everything works as expected.

Steps to reproduce the problem

  1. Create a form that saves a date to an Entity property and then later uses that date such as this one
  2. Make sure that there is the offline column on the entities sheet and that its value is set to yes
  3. Fill out and finalize a submission
  4. Open the form again and see the crash
  5. Open the Entities browser and the property has been incorrectly re-formated
    Screenshot_20241114_154559

Expected behavior

Entity properties should always be treated as opaque strings. They should be saved and retrieved exactly as entered into the form.

Other information

Something along the way is detecting a date and reformatting it. I don't think it's sqlite because I'm pretty sure sqlite stores dates in iso8601 format.

@grzesiek2010
Copy link
Member

@lognaturel
this issue is about properties but we can also save dates as labels for example so in those other cases it shouldn't be formated as well right?

Open the form again and see the crash

Could you tell something more about this crash? I haven't experienced it at least using my forms: #6514
Are you sure it is connected?

@lognaturel
Copy link
Member Author

Yes, same with labels which are system-known properties.

Your fix looks right to me. Were you able to reproduce the crash with the form I linked to? The issue is that there’s a format-date call on the property value that was saved so if that is not formatted correctly the function throws an exception.

@grzesiek2010
Copy link
Member

Were you able to reproduce the crash with the form I linked to?

I couldn’t use your form at all. When I added it to Central and tried to open it, I encountered this error:
image

I needed a smaller form for testing anyway, so I built my own and didn’t investigate what’s wrong with yours.

@lognaturel
Copy link
Member Author

Did you put any values in the Entity List? You should be able to use the values in the facilities sheet to download a CSV and populate facilities. See https://forum.getodk.org/t/restrict-duplicate-entries-submission-from-same-facility/47927/8?u=ln

@grzesiek2010
Copy link
Member

I did... it looks like the csv is not marked as an entity file during downloading from Central:
image

It is late maybe I'm doing something wrong or there is a bug somewhere.

@lognaturel
Copy link
Member Author

Very interesting! I think that might happen when the Entity List is empty. Maybe when you're ready to look at it again with fresh eyes you can add some facilities to the list. The form isn't expected to work with no facilities specified.

@grzesiek2010
Copy link
Member

It is not empty:
image

@lognaturel
Copy link
Member Author

Intriguing! Ok, I'll look into it a bit as well and let you know if I see anything interesting.

@lognaturel
Copy link
Member Author

We figured this out -- the Entity List wasn't attached to the form because a static CSV was. Now it's crashing as expected. 🎉

@github-project-automation github-project-automation bot moved this from in progress to done in ODK Collect Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: done
Development

Successfully merging a pull request may close this issue.

2 participants