feat(grading): support in-memory PGlite backend for grading endpoints#19
Open
simonmysun wants to merge 2 commits into
Open
feat(grading): support in-memory PGlite backend for grading endpoints#19simonmysun wants to merge 2 commits into
simonmysun wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Enables the SQL assessment service grading endpoints to run end-to-end against an in-process PGlite database by routing query execution through a shared pgliteInstances registry and a backend-agnostic RowQueryFn, rather than requiring a TypeORM DataSource (external Postgres).
Changes:
- Introduces
RowQueryFn+makePGliteRowQueryFnand refactors grading comparators/services to execute queries via this backend-agnostic function. - Updates
GradingControllerto resolve either Postgres or PGlite connections and to use a unifiedcleanuphook (no-op for shared PGlite). - Adds unit/integration tests and extends the smoke test script to cover grading endpoints on PGlite; removes the deprecated
GRADING_PGLITE_NOT_SUPPORTEDmessage.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| services/sql-assessment-service/src/shared/utils/database-utils.ts | Adds RowQueryFn abstraction plus makePGliteRowQueryFn and PGlite key generation. |
| services/sql-assessment-service/src/grading/result-set-comparator.ts | Refactors result-set comparison/executability checks to use RowQueryFn and normalizes DB error extraction. |
| services/sql-assessment-service/src/grading/query-grading-service.ts | Threads RowQueryFn through the grading pipeline instead of a DataSource. |
| services/sql-assessment-service/src/grading/comparators/execution-plan-comparator.ts | Refactors EXPLAIN plan retrieval to execute via RowQueryFn. |
| services/sql-assessment-service/src/grading/grading-controller.ts | Adds PGlite backend resolution, shared-instance handling, and unified cleanup across endpoints. |
| services/sql-assessment-service/src/shared/i18n/messages.ts | Removes GRADING_PGLITE_NOT_SUPPORTED message key and translations. |
| services/sql-assessment-service/test/shared/pglite-row-query-fn.test.ts | Adds unit tests for PGlite RowQueryFn shape invariants and comparator integration. |
| services/sql-assessment-service/test/grading/pglite-grading-controller.test.ts | Adds integration tests for grading + compare endpoints backed by PGlite. |
| services/sql-assessment-service/scripts/smoke-test.sh | Adds smoke coverage for grading endpoints on PGlite. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+486
to
+494
| // Resolve a backend-agnostic executor for either PGlite or PostgreSQL. | ||
| let databaseKey: string; | ||
| let runQuery: RowQueryFn; | ||
| let cleanup: () => Promise<void>; | ||
| let schema: string; | ||
|
|
||
| const databaseKey = generateDatabaseKey( | ||
| connectionInfo.host!, | ||
| connectionInfo.port!, | ||
| connectionInfo.schema!, | ||
| ); | ||
| if (!isDatabaseRegistered(databaseKey)) { | ||
| return res | ||
| .status(400) | ||
| .json({ message: t('DATABASE_NOT_REGISTERED', lang) }); | ||
| if ((connectionInfo as any)?.type === 'pglite') { | ||
| const validated = this.resolvePGliteConnection( | ||
| connectionInfo as any, |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Grading endpoints previously rejected PGlite connections with a 400
GRADING_PGLITE_NOT_SUPPORTED because the comparators were hard-wired to
a TypeORM DataSource. Route PGlite connections through the shared
pgliteInstances registry so /grade and /compare/* run end-to-end without
an external PostgreSQL server.