I’ve always thought that the PyDataSet type was just a wrapper around the DataSet, to make the getters more pythonesque.
However, I recently bumped on this discrepancy between both:
originalPyDataSet = system.db.runQuery("SELECT column FROM my_table")
newDataSet = system.dataset.toDataSet(originalPyDataSet)
print newDataSet.getValueAt(0, "column")
print newDataSet.getValueAt(0, "Column")
print originalPyDataSet[0]["column"]
print originalPyDataSet[0]["Column"] # < this crashes because "Column" is not found
Now try to guess what this script will do, will it error out (where?), or what will be printed? Pretty impossible right?
headers = ["column", "COLUMN"]
data = [["value", "VALUE"]]
dataSet = system.dataset.toDataSet(headers, data)
pyDataSet = system.dataset.toPyDataSet(dataSet)
print dataSet.getValueAt(0, "column")
print dataSet.getValueAt(0, "COLUMN")
print pyDataSet[0]["column"]
print pyDataSet[0]["COLUMN"]
Or can you guess what happens when you bind the above dataset to a table?
I wonder why this behavior was chosen. If anything, the PyDataSet should be case insensitive as it’s returned as the result of a SQL query (and most databases have some case insensitiveness). While the DataSet is more often being constructed in scripts (being what binds to tables, and PyDataSets can’t be created from scratch either).