Repository navigation
fix(query): allow digits in ORDER BY column names - #3894
Conversation
|
@PerryLink is attempting to deploy a commit to the Nuxt Team on Vercel. A member of the Team first needs to authorize it. |
commit: |
|
No actionable comments were generated in the recent review.
|
nuxt/content#3894 merged at 12:44:39Z, after the 12:35:07Z derivation: 408 credited in 90, 441 across 92, 162 open across 124.
Resolves #3893
assertSafeQuery()validated ORDER BY column names with/^("[a-zA-Z_]+"|[a-zA-Z_]+) (ASC|DESC)$/, which rejects any schema field containing a digit, while the SELECT column checks at the top of the same function use/^"[a-z_]\w+"$/iand accept them. Server/SSR queries throughqueryCollection('docs').order('publishedAt2', 'DESC')therefore returned a 500 (Invalid query: ORDER BY clause must contain valid column names followed by ASC or DESC), even though.where('publishedAt2', ...)and.select('publishedAt2')worked and the client WASM path (which bypasses the validator) sorted correctly.Widen the ORDER BY pattern the same way #3100 widened it for uppercase names:
[a-zA-Z_]\w*so digits are allowed after the first character, matching whatcollectionQueryBuilderemits for arbitrary zod object keys.Tests
test/unit/assertSafeQuery.test.tsadds cases forORDER BY "field1" DESC,ORDER BY id ASC, publishedAt2 DESC, thecollectionQueryBuilderoutput for a digit field, and keepsORDER BY "a b" DESCrejected.test/unitsuite: 408 passed, 1 skipped; the only failing file is the pre-existingtest/unit/utils.test.ts(imports@nuxt/content/utilsfrom an unbuiltdist), which fails before this change too.