Changelog - 2026-09-26
Order entries: one parser, and a 400 for malformed input
Feature Behavior ChangeIn one line. Every order entry (relational, Typesense, Meilisearch) is read by one exported parseOrderEntry, and an entry it cannot make sense of is a 400 instead of a silent truncation.
typescript
import { parseOrderEntry } from '@venizia/ignis-filter';
parseOrderEntry({ entry: 'createdAt DESC' }); // { field: 'createdAt', direction: 'desc' }
parseOrderEntry({ entry: 'name' }); // { field: 'name', direction: 'asc' }What changed
parseOrderEntryis a new export of@venizia/ignis-filter(also from@venizia/ignis-kerneland@venizia/ignis), with the newTSortDirectionandTParsedOrderEntrytypes.- An entry with more than two tokens is a 400.
'createdAt DESC NULLS LAST'used to sort oncreatedAt DESCand dropNULLS LAST. IGNIS never gave aNULLS LASTorFIRSTclause any effect. - An empty entry (
''or whitespace) is a 400. It used to read as "column not found". - Direction error messages changed. They now start with
[parseOrderEntry], for example[parseOrderEntry] Invalid direction | entry: "name RANDOM" | Expected: 'ASC' or 'DESC', and the other cases read[parseOrderEntry] Too many tokens ...and[parseOrderEntry] Order entry has no field .... Status codes are unchanged for cases that were already errors. Unknown-column messages (Column NOT FOUND | key: '<key>') are unchanged. - The entry in a message is
JSON.stringify-quoted, so a newline or other ASCII control character is escaped. DEL, the C1 range, andU+2028/U+2029still pass through raw. - Only ASCII whitespace separates a field from its direction. A non-breaking space or another Unicode space no longer splits
'name<NBSP>DESC'; the whole string is read as one field name.
toOrderBy can sort by a joined column or a computed expression
FeatureIn one line. IRelationalQueryDialect.toOrderBy takes a new expressions option: a map from the name an order entry uses to a Drizzle column or SQL.
typescript
import { sql } from 'drizzle-orm';
const orderBy = queryDialect.toOrderBy({
tableName: 'item',
schema: itemTable,
order: ['groupLabel ASC', 'displayName DESC'],
expressions: {
groupLabel: groupTable.label, // a column on a joined table
displayName: sql`COALESCE(${itemTable.nickname}, ${itemTable.name})`, // a computed value
},
});
// ORDER BY "group"."label" asc, COALESCE("item"."nickname", "item"."name") desc, "item"."id" ascA key resolves as an own key of expressions first (an inherited name like constructor never matches), then as a JSON path, then as a schema column. The id ASC tie-breaker still closes the list unless an entry names id; an expression keyed id never counts as naming it. See Fields, Order & Pagination.
Who is affected
- Well-formed entries (
'field'or'field ASC|DESC', ASCII whitespace). No change. - An entry with more than two tokens, or an empty entry. Now a
400. Drop the extra tokens. - An entry using a non-ASCII space between field and direction. Now one field name, likely an unknown column. Use a regular space or tab.
- Code matching the old direction-error text (
Invalid direction: '...' | Expected:,Invalid sort direction '...' for field '...'). Match the new[parseOrderEntry] Invalid directionmessage. - There is no flag to keep the old parser. Adopt
expressionsonly if you want a joined or computed sort.