Skip to content

test(nextly): the search-path probe sets up through the connection it reads - #1727

Merged
mobeenabdullah merged 2 commits into
mainfrom
fix/probe-fixture-goes-through-drizzle
Sep 10, 2026
Merged

mobeenabdullah merged 2 commits into
mainfrom
fix/probe-fixture-goes-through-drizzle

Conversation

@mobeenabdullah

Copy link
Copy Markdown
Collaborator

Follows #1721, from a Codex P1 that landed as it merged. Test-only, so no changeset.

What was wrong

The search-path probe set its fixture up with pg.Client.query directly. This
repository's rule is that database access is Drizzle-only, and the exemption a
test might claim — that a fixture is not product code — does not hold here: those
statements establish the session state the assertions depend on, so they have
to travel the same path the reads do.

Setup and teardown now go through db.execute(sql.raw(...)) on the same
client-bound instance, so the SET search_path still lands on the connection
that reads. The Client is kept and still closed in afterAll — it is what pins
the session, so nothing else can release it.

Where I did not follow the advice, and why

The review also asked me to "derive table DDL through the production helpers
rather than introducing a second DDL implementation". I have not, and I want to
be explicit rather than quietly partial.

These fixture tables are synthetic: a decoy and a subject that exist only to
be resolved by the search path, with no production counterpart. The hazard that
rule guards — a fixture copying a real table's definition and then drifting from
it — has nothing to drift from here. Deriving them from a real table would couple
this file to that table's shape and change what it measures.

Measured rather than asserted: this repository's own PostgreSQL integration tests
create synthetic probe tables inline for the same reason.

packages/nextly/src/database/__tests__/integration/schema-push.integration.test.ts:74   CREATE TABLE "dc_int_products"
packages/nextly/src/di/load-dynamic-slugs.integration.test.ts:33                        CREATE TABLE dynamic_collections (slug TEXT)

getSchemaEventsDdl, the helper the rule names, builds one specific production
table. There is no helper for a two-column decoy, and writing one would be the
second DDL implementation the advice warns against.

The reasoning is now in the file's docblock, so the next reader sees why these
are hand-written and does not have to re-litigate it.

Gates

nextly check-types 0 · lint 0 · the probe is still collected by
vitest.integration.config.ts (5 tests, skipped locally for the documented
missing-URL reason).

⚠️ Still not executed anywhere I can see: no Docker or PostgreSQL is reachable
from this machine, and #1721 merged while its Postgres leg was queued. That leg
is running on main now and is the first real verdict on these assertions.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-10T13:09:22.208856Z 9be1fb8 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: dbcca5eb-1966-472c-9e39-8578c0558c0f

📥 Commits

Reviewing files that changed from the base of the PR and between 89bb57c and 9be1fb8.

📒 Files selected for processing (1)
  • packages/nextly/src/domains/schema/pipeline/diff/__tests__/introspect-search-path.integration.test.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mobeenabdullah

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fb2731bf7f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +68 to +70
// 🔴 Through Drizzle, not `client.query`. Database access in this repository
// is Drizzle-only, and the exemption a test might claim — that a fixture is
// not product code — does not apply to the thing under test here: these

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep the setup comment focused on the code

This comment explains compliance with repository policy and rebuts a hypothetical test exemption instead of only explaining why the helper uses the client-bound Drizzle instance. Keep the same-session rationale, but remove the policy/review discussion so the comment follows the repository's enforced comment convention.

AGENTS.md reference: AGENTS.md:L277-L279

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, and it is a rule I had read an hour earlier while checking the one about
DDL helpers — AGENTS.md, same section: comments describe the code, never
conversations. I argued with a review inside the source file.

Both comments are rewritten to say only why the code is what it is:

  • the setup helper now explains that these statements establish the session state
    the assertions depend on, so the SET search_path has to be sent the way the
    reads are sent;
  • the docblock says the fixture tables are synthetic and written out rather than
    derived because deriving them would tie the file to another table's shape,
    with no mention of any rule or exemption.

The reasoning about which rule applies belongs in the PR conversation, which is
where I have put it.

@pkg-pr-new

pkg-pr-new Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@nextlyhq/adapter-drizzle

npm i https://pkg.pr.new/@nextlyhq/adapter-drizzle@9be1fb8

@nextlyhq/adapter-mysql

npm i https://pkg.pr.new/@nextlyhq/adapter-mysql@9be1fb8

@nextlyhq/adapter-postgres

npm i https://pkg.pr.new/@nextlyhq/adapter-postgres@9be1fb8

@nextlyhq/adapter-sqlite

npm i https://pkg.pr.new/@nextlyhq/adapter-sqlite@9be1fb8

@nextlyhq/admin

npm i https://pkg.pr.new/@nextlyhq/admin@9be1fb8

@nextlyhq/admin-css

npm i https://pkg.pr.new/@nextlyhq/admin-css@9be1fb8

@nextlyhq/blocks-engine

npm i https://pkg.pr.new/@nextlyhq/blocks-engine@9be1fb8

@nextlyhq/blocks-react

npm i https://pkg.pr.new/@nextlyhq/blocks-react@9be1fb8

@nextlyhq/builder

npm i https://pkg.pr.new/@nextlyhq/builder@9be1fb8

create-nextly-app

npm i https://pkg.pr.new/create-nextly-app@9be1fb8

@nextlyhq/eslint-plugin

npm i https://pkg.pr.new/@nextlyhq/eslint-plugin@9be1fb8

nextly

npm i https://pkg.pr.new/nextly@9be1fb8

@nextlyhq/plugin-form-builder

npm i https://pkg.pr.new/@nextlyhq/plugin-form-builder@9be1fb8

@nextlyhq/plugin-page-builder

npm i https://pkg.pr.new/@nextlyhq/plugin-page-builder@9be1fb8

@nextlyhq/plugin-sdk

npm i https://pkg.pr.new/@nextlyhq/plugin-sdk@9be1fb8

@nextlyhq/plugin-seo

npm i https://pkg.pr.new/@nextlyhq/plugin-seo@9be1fb8

@nextlyhq/storage-s3

npm i https://pkg.pr.new/@nextlyhq/storage-s3@9be1fb8

@nextlyhq/storage-uploadthing

npm i https://pkg.pr.new/@nextlyhq/storage-uploadthing@9be1fb8

@nextlyhq/storage-vercel-blob

npm i https://pkg.pr.new/@nextlyhq/storage-vercel-blob@9be1fb8

@nextlyhq/ui

npm i https://pkg.pr.new/@nextlyhq/ui@9be1fb8

commit: 9be1fb8

@github-actions github-actions Bot added the scope: core nextly label Sep 10, 2026
@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Whole-Repository Code Hygiene Summary

Full dead-code, duplication, and complexity report for the PR branch as it stands now. Playground is excluded. Quality gate enforcement on introduced issues is performed by the Changed files job.

🌿 Fallow

Warning

Review needed

⚠️ 73 code issues · ⚠️ 694 clone groups · ⚠️ 1046 health findings

See inline review comments for per-finding details.

Code issues (73)
Category Count
Unused files 2
Unused exports 5
Unused dependencies 19
Unused devDependencies 6
Unresolved imports 2
Unlisted dependencies 1
Circular dependencies 38
Duplication (694 groups · 29014 lines · 4.1%)
Locations Lines Tokens
schemas/_dialect-bundles/mysql.relations.ts:40-134
schemas/_dialect-bundles/postgres.relations.ts:40-134
schemas/_dialect-bundles/sqlite.relations.ts:40-134
95 593
cli/commands/db-sync-demote.ts:70-75
cli/commands/db-sync-promote.ts:38-43
cli/commands/dev-build.ts:100-105
cli/commands/dev-build.ts:179-184
cli/commands/dev-build.ts:299-304
cli/commands/dev-build.ts:411-416
cli/commands/dev-build.ts:552-557
cli/commands/dev-server.ts:575-580
cli/commands/dev-server.ts:840-845
cli/commands/dev-server.ts:1143-1148
cli/commands/migrate-field-groups.ts:110-115
6 70
entries/EntryList/EntryTableSkeleton.tsx:74-98
collection/components/CollectionTableSkeleton.tsx:94-118
field-group/components/FieldGroupTableSkeleton.tsx:90-114
plugins/components/PluginsTableSkeleton.tsx:86-110
singles/components/SinglesTableSkeleton.tsx:77-101
src/components/table-skeleton.tsx:100-124
25 89
collections/config/validate-config.ts:380-433
field-groups/config/validate-field-group.ts:185-238
singles/config/validate-single.ts:190-243
54 152
dispatcher/handlers/collection-dispatcher.ts:922-964
field-groups/services/field-group-table-provisioning.ts:186-236
singles/services/reconcile-single-companion.ts:110-160
51 149

… and 689 more groups.

Across 423 files.

Complexity (1046 functions above threshold)
File Function Severity Cyclomatic Cognitive CRAP Lines
singles/services/single-mutation-service.ts:981 <arrow> critical 251 ! 324 ! 13859.2 ! 1625
collections/services/collection-mutation-service.ts:6209 <arrow> critical 174 ! 177 ! 6713.6 ! 1301
src/init/reload-config.ts:1319 applyReload critical 144 ! 228 ! 4623 ! 1433
shared/lib/entry-validation.ts:223 validateFieldValue critical 109 ! 157 ! 2675.3 ! 432
blocks-engine/src/measure-bytes.ts:646 surveyDocument critical 102 ! 250 ! 137.1 ! 658

4980 files, 76026 functions analyzed (thresholds: cyclomatic > 20, cognitive > 15, CRAP >= 30)

Codebase health

Metric Value
Maintainability 91.7 / 100
Avg complexity 1.8

Tip

Run fallow fix --dry-run to preview auto-fixes.
Add /** @public */ above exports to preserve them.

@mobeenabdullah

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 9be1fb8063

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@mobeenabdullah
mobeenabdullah merged commit 31ecaff into main Sep 10, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant