(core) Use MixedTypesKey for sort_by arg of lookupRecords to avoid errors in Python 3

Summary: title

Test Plan: Added python unit test. Seems like the first test of sort_by in the whole codebase.

Reviewers: dsagal

Reviewed By: dsagal

Differential Revision: https://phab.getgrist.com/D3124
This commit is contained in:
Alex Hall
2021-11-09 18:07:58 +02:00
parent ecb30eebb8
commit 267640c277
4 changed files with 58 additions and 10 deletions

View File

@@ -746,3 +746,30 @@ return ",".join(str(r.id) for r in Students.lookupRecords(firstName=fn, lastName
[102, [102, 103], [101, 103], [103], [102]],
[103, [], [], [], []],
])
def test_sort_by(self):
self.load_sample(testutil.parse_test_sample({
"SCHEMA": [
[1, "Table1", [
[1, "num", "Numeric", False, "", "", ""],
[2, "lookup", "Any", True, "Table1.lookupRecords(sort_by='num').num", "", ""],
]]
],
"DATA": {
"Table1": [
["id", "num"],
[1, 2],
[2, 1],
[3, 'foo'],
[4, 3],
[5, None],
[6, 0],
]
}
}))
self.assertTableData(
"Table1", cols="subset", rows="subset", data=[
["id", "lookup"],
[1, [None, 0, 1, 2, 3, 'foo']],
])