-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(core): batch taxonomy term counts under D1's compound-SELECT limit #2331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
khoinguyenpham04
merged 6 commits into
emdash-cms:main
from
MA2153:fix/taxonomy-term-counts-compound-select
Aug 5, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5312e0f
fix(core): batch taxonomy term counts under D1's compound-SELECT limit
MA2153 40fae20
fix(core): drop issue references from term-count test block
MA2153 f00555b
fix(core): scope the compound-SELECT split to backends that cap it
MA2153 8552e64
Merge branch 'main' into fix/taxonomy-term-counts-compound-select
MA2153 6ea6f77
Update packages/cloudflare/tests/db/d1-dialect.test.ts
MA2153 060499c
fix(core): reject a malformed compoundSelectLimit at the adapter probe
MA2153 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "emdash": patch | ||
| --- | ||
|
|
||
| Fixes the taxonomy term list returning a 500 and rendering empty on Cloudflare D1 when a taxonomy declares six or more collections. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
packages/core/tests/unit/database/compound-select-limit.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import type { Kysely as KyselyType } from "kysely"; | ||
| import { Kysely, SqliteAdapter, SqliteDialect } from "kysely"; | ||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| import { compoundSelectLimit } from "../../../src/database/dialect-helpers.js"; | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any -- adapter probe takes any instance | ||
| type AnyDb = KyselyType<any>; | ||
|
|
||
| function stockDb(): AnyDb { | ||
| return new Kysely({ dialect: new SqliteDialect({ database: {} as never }) }); | ||
| } | ||
|
|
||
| function dbDeclaring(limit: unknown): AnyDb { | ||
| class DeclaringAdapter extends SqliteAdapter { | ||
| readonly compoundSelectLimit = limit; | ||
| } | ||
| class DeclaringDialect extends SqliteDialect { | ||
| override createAdapter(): SqliteAdapter { | ||
| return new DeclaringAdapter(); | ||
| } | ||
| } | ||
| return new Kysely({ dialect: new DeclaringDialect({ database: {} as never }) }); | ||
| } | ||
|
|
||
| describe("compoundSelectLimit", () => { | ||
| it("returns null for an adapter that declares no ceiling", () => { | ||
| expect(compoundSelectLimit(stockDb())).toBeNull(); | ||
| }); | ||
|
|
||
| it("returns the declared ceiling", () => { | ||
| expect(compoundSelectLimit(dbDeclaring(5))).toBe(5); | ||
| expect(compoundSelectLimit(dbDeclaring(1))).toBe(1); | ||
| }); | ||
|
|
||
| it.each([ | ||
| ["zero", 0], | ||
| ["negative", -1], | ||
| ["NaN", Number.NaN], | ||
| ["Infinity", Number.POSITIVE_INFINITY], | ||
| ["fractional", 2.5], | ||
| ["a numeric string", "5"], | ||
| ["null", null], | ||
| ])("throws for a %s ceiling instead of returning it", (_label, limit) => { | ||
| expect(() => compoundSelectLimit(dbDeclaring(limit))).toThrow( | ||
| /compoundSelectLimit.*positive integer/s, | ||
| ); | ||
| }); | ||
|
|
||
| it("names the offending adapter so the dialect can be found", () => { | ||
| expect(() => compoundSelectLimit(dbDeclaring(0))).toThrow(/DeclaringAdapter/); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.