Fix SQL schema selector execution#1518
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
Summary by CodeRabbit
WalkthroughThis PR implements end-to-end schema-aware SQL execution and linting in Prisma Studio. The active schema is now threaded through the entire platform: BFF requests include an optional 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
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. Comment |
|
Compute preview deployed. Branch: |
There was a problem hiding this comment.
Warning
CodeRabbit couldn't request changes on this pull request because it doesn't have sufficient GitHub permissions.
Please grant CodeRabbit Pull requests: Read and write permission and re-run the review.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@ui/studio/views/sql/SqlView.test.tsx`:
- Line 15: The mock useNavigationMock currently types schemaParam as always
string which prevents testing the fallback in getActiveSqlSchema; update the
mock signature or add an additional mock case so useNavigationMock can return
schemaParam as null and undefined and add tests that invoke getActiveSqlSchema
with those returns to assert the fallback behavior. Specifically adjust the
vi.fn typing for useNavigationMock (and any other occurrences at lines ~418-422)
to allow schemaParam?: string | null | undefined, then add/modify tests that set
useNavigationMock to return { schemaParam: null } and { schemaParam: undefined }
and assert getActiveSqlSchema exercises the fallback branch.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 661ca726-9e57-44c1-8d65-199dbba29ce0
📒 Files selected for processing (27)
.changeset/silver-schema-sql.mdArchitecture/navigation-url-state.mdArchitecture/sql-editor-intelligence.mdArchitecture/sql-view.mdFEATURES.mdREADME.mddata/adapter.tsdata/bff/bff-client.test.tsdata/bff/bff-client.tsdata/executor.tsdata/pglite/index.tsdata/postgres-core/adapter.test.tsdata/postgres-core/adapter.tsdata/postgres-core/search-path.test.tsdata/postgres-core/search-path.tsdata/postgres-core/sql-editor.adapter.test.tsdata/postgresjs/index.test.tsdata/postgresjs/index.tsdemo/ppg-dev/seed-database.tsdemo/ppg-dev/server.tsdemo/ppg-dev/sql-lint.tsui/studio/Navigation.test.tsxui/studio/Navigation.tsxui/studio/views/sql/SqlView.test.tsxui/studio/views/sql/SqlView.tsxui/studio/views/sql/sql-lint-source.test.tsui/studio/views/sql/sql-lint-source.ts
Summary
Fixes schema selector handling for SQL execution and related Studio navigation. The SQL view now treats the active schema selector as the default namespace for unqualified identifiers, so queries like
select * from order_itemswork whentest_appis selected instead of incorrectly resolving throughpublic.Root Cause
The SQL view read the selected schema from URL state, but raw SQL execution and SQL linting did not pass it through the adapter/BFF/executor path. Postgres execution therefore used the connection default
search_path, and sidebar navigation also dropped theschemaURL param when switching between database views.What Changed
schemasupport to raw SQL and SQL lint adapter/BFF contracts.search_pathfor raw execution and lint/EXPLAIN paths.test_appschema so non-public schema behavior is reproducible locally.Validation
pnpm changeset status --since origin/mainpnpm vitest run ui/studio/Navigation.test.tsx ui/hooks/use-navigation.test.tsx ui/studio/views/sql/SqlView.test.tsx ui/studio/views/sql/sql-lint-source.test.ts data/bff/bff-client.test.ts data/postgres-core/search-path.test.ts data/postgres-core/adapter.test.ts data/postgres-core/sql-editor.adapter.test.ts data/postgresjs/index.test.tspnpm typecheckpnpm buildCOREPACK_ENABLE_STRICT=0 pnpm check:exportsschema: test_app,select * from order_items order by idreturns 3 rows.schema: test_app, SQL lint forselect * from order_itemsreturns no diagnostics.schema: public, SQL lint for the same query reportsrelation "order_items" does not exist.Known Local Validation Limits
pnpm test:data/pnpm testare blocked locally by missing MySQL (ECONNREFUSED) and a Vitest worker OOM in the full suite.pnpm check:exportsis blocked by Corepack package-manager enforcement because the script shells out tonpm pack; rerunning withCOREPACK_ENABLE_STRICT=0passes.