Open robingram opened 5 years ago
This is actually more serious than I first thought. Because the first column is ID this triggers a bug in Excel:
Export a gridfields as CSV. Open in Excel, edit one of the fields and re-save. Try to open the file again in Excel. This results in an error message because of a file type mismatch. Excel thinks it is a SYLK file now. If you open it in a text editor you'll find that it is now tab separated and obviously won't import properly.
Also applies to other modules, including silverstripe-registry
.
Note also that the exported CSV no longer matches the specification that is displayed in the import dialogue, unless the additional columns are removed.
@robingram are you prepared to open a PR to address this?
The excel issue with opening CSVs that have a primary column called ID
is a "known issue" in excel, not a lot we can do about that other than tell people to open their CSVs via the "import CSV" wizard
@dhensby Can do but I'd prefer to address it on silverstripe-registry
first as that's more urgent for us.
What's the recommendation? Two options that come to mind are set it back to what it was before, assuming that singleton($this->modelClass)->db()
is still valid, or to remove the override altogether so it falls back to summary_fields
. The latter allows for the fields to be overridden but might be problematic for the duplicate check in this module.
...Though mapping summary fields in the same way that it does for databaseFields
would solve that by making sure that the headings match the field name rather than the header text. The problem would come if someone took FromBase
out summary_fields
.
A PR has gone into silverstripe-registry
based on summary_fields
but I'm not sure how to proceed with this module. If we use summary_fields
then it could potentially be overridden to remove FromBase
and then the duplicate check of the importer will throw an error. I'd argue that it's a field that's pretty fundamental to the module though so maybe that risk is small.
We could ensure that FromBase
is always in the export field list but that seems sneaky.
Thoughts anyone?
A PR has gone into
silverstripe-registry
link?
https://github.com/silverstripe/silverstripe-registry/pull/51
Robbie merged it.
Just a question really. In the SS4 version of this module the ModelAdmin overrides
getExportFields
and queries the database schema to get the field list:DataObject::getSchema()->databaseFields($this->modelClass)
. This returns all fields including ID, LastEdited and Created.Is this the intended behaviour? Previously it used
singleton($this->modelClass)->db()
and so only exported three fields.