Adding GridFieldSortableRows to the wrong column causes massive data loss #12

Closed
TheFrozenFire opened this Issue Oct 12, 2012 · 4 comments

Comments

2 participants

GridFieldSortableRows would seem to automatically overwrite the contents of every field in each row incrementally, as soon as it's added, if it's non-numeric. I unwittingly added the component to the wrong field, and ended up having to restore from a database backup, because it overwrote my Text column with integer values.

Owner

UndefinedOffset commented Oct 12, 2012

Ya it's pretty unforgiving lol, best to test locally before you do things. I may add a check to make sure the column is an integer column before it does the change though that should help when it comes to text fields. Basically it indexes the sort column when it displays the list in the grid field to ensure that all records have a sort index so while in your instance this caused issues. Its working as expected.

This was done in a development environment. I would say that "being unforgiving" is a critical bug for this sort of tool. The intention of a GridFieldComponent is to provide interface functionality. One does not ordinarily expect it to wipe data out when simply adding it.

In my case, I was looking for a way to sort a GridField based on a particular field (having forgotten to simply sort my DataList). If I was not making regular backups of my data, it likely would have cost me a couple hours of hard work, re-importing a whole bunch of data.

I would definitely say that it's important to check if the field being sorted is an Integer-type DBField, and just throw a harsh error if it's not. Moreover, I wouldn't suggest overwriting a field's contents at all, unless it's empty.

Owner

UndefinedOffset commented Oct 12, 2012

Ya I think simply checking the field to insure it is a int will fix because it only updates the field values if it is 0. So empty :)

Owner

UndefinedOffset commented Oct 12, 2012

Addressed in master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment