mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-08-30 23:27:26 +02:00
Fix cookie defaults on the bootstrapped workspace and tie order in ordered atoms
`Workspace::default()` is derived, so the first workspace was created with `setting_send_cookies` and `setting_store_cookies` false, contradicting the model's `default_true` serde defaults and the migration's DEFAULT TRUE. `createOrderedModelAtom` returned -1 for equal keys, an inconsistent comparator, so same-millisecond `http_response_event` rows came out of V8's sort reversed.
This commit is contained in:
@@ -61,7 +61,9 @@ export function createOrderedModelAtom<M extends AnyModel["model"]>(
|
||||
const modelData = data[modelType] ?? {};
|
||||
return Object.values(modelData).sort(
|
||||
(a: ExtractModel<AnyModel, M>, b: ExtractModel<AnyModel, M>) => {
|
||||
const n = a[field] > b[field] ? 1 : -1;
|
||||
// NOTE: ties must return 0, or the comparator is inconsistent and V8 reorders
|
||||
// equal-keyed rows. Sort is stable, so 0 preserves store (DB) insertion order.
|
||||
const n = a[field] === b[field] ? 0 : a[field] > b[field] ? 1 : -1;
|
||||
return order === "desc" ? n * -1 : n;
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user