Skip to content

feat(grading): support in-memory PGlite backend for grading endpoints#19

Open
simonmysun wants to merge 2 commits into
HTW-ALADIN:masterfrom
simonmysun:master
Open

feat(grading): support in-memory PGlite backend for grading endpoints#19
simonmysun wants to merge 2 commits into
HTW-ALADIN:masterfrom
simonmysun:master

Conversation

@simonmysun

Copy link
Copy Markdown
Contributor

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.

Copilot AI review requested due to automatic review settings July 1, 2026 17:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 + makePGliteRowQueryFn and refactors grading comparators/services to execute queries via this backend-agnostic function.
  • Updates GradingController to resolve either Postgres or PGlite connections and to use a unified cleanup hook (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_SUPPORTED message.

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,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants