dkan
dkan copied to clipboard
Use same sanitization when comparing properties
When applying date formats defined in the data dictionary we are comparing the dictionary metadata to the query properties that have been sanitized, so we must also sanitize the metadata fields. ""start_date"" !== "start_date"
Warning: Trying to access array offset on value of type null in Drupal\common\Storage\SelectFactory->addDateExpressions() (line 108 of /mnt/www/html/datamedicaidstg/docroot/modules/contrib/dkan/mo
dules/common/src/Storage/SelectFactory.php)
Warning: Undefined array key "start_date" in Drupal\common\Storage\SelectFactory->addDateExpressions() (line 108 of /mnt/www/html/datamedicaidstg/docroot/modules/contrib/dkan/modules/common/src/Storage/SelectFactory.php)
Steps to reproduce
- [ ] checkout 2.x
- [ ] Enable dblog
- [ ] Add a data dictionary defining a data type = date, format = other, Other format = %m/%d/%Y, OR use the provided POST below.
POST https://dkan.ddev.site/api/1/metastore/schemas/data-dictionary/items HTTP/1.1
Content-Type: application/json
Authorization: Basic admin:admin
{
"data": {
"title": "Test Dictionary",
"fields": [
{
"name": "string",
"title": "String example",
"type": "string",
"format": "default"
},
{
"name": "number",
"title": "Number",
"type": "number",
"format": "default"
},
{
"name": "start_date",
"title": "Start Date",
"type": "date",
"format": "%m/%d/%Y"
}
]
}
}
- [ ] Create a dataset with the attached data file as your resource. Enter the data dictionary endpoint that you just created into the distribution Data Dictionary field --> test-data.csv
- [ ] Add "application/vnd.tableschema+json" as Data Dictionary Type
- [ ] Save and run the import queues
ddev drush queue:run localize_import
ddev drush queue:run datastore_import
ddev drush queue:run post_import
- [ ] View the datastore and confirm the date column has been typed correctly as a date type.
- [ ] Now hit the csv download API using the identifier of your dataset: https://dkan.ddev.site/api/1/datastore/query/{datasetUUID}/0/download?format=csv
- [ ] Notice the date column values are in ISO format rather than the mm/dd/year of the original file
- [ ] View the recent log messages, https://dkan.ddev.site/admin/reports/dblog, you will see the errors listed above
QA Steps
- [ ] Checkout this branch
- [ ] If you already went through the steps above, set the datastore settings to "Last Update" and save
- [ ] Edit the test dataset, change the Last Update value and save.
- [ ] Run the import queues again (localize, datastore, post)
- [ ] Try the csv download API again https://dkan.ddev.site/api/1/datastore/query/{datasetUUID}/0/download?format=csv
- [ ] Confirm your csv shows the dates in mm/dd/YYYY format