Skip to content

Conversation

@Artuomka
Copy link
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings January 13, 2026 13:59
@Artuomka Artuomka enabled auto-merge January 13, 2026 13:59
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request introduces a comprehensive saved database queries module that allows users to create, read, update, delete, and execute saved SQL queries within connections. The implementation includes query safety validation to prevent destructive operations, entity encryption for query text, and full CRUD operations with extensive test coverage.

Changes:

  • Added SavedDbQueryEntity with database migration and relationship to ConnectionEntity
  • Implemented complete CRUD operations for saved queries with use cases, DTOs, and repository layer
  • Added query safety validation utility that prevents INSERT, UPDATE, DELETE, and other destructive SQL operations
  • Created comprehensive e2e test suite covering all endpoints and security validations
  • Reformatted indentation in PostgreSQL and MySQL data access object files (spaces to tabs)

Reviewed changes

Copilot reviewed 37 out of 39 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
backend/src/migrations/1767976893755-AddSavedDBQueryEntity.ts Database migration creating saved_db_query table with foreign key to connection
backend/src/entities/visualizations/saved-db-query/saved-db-query.entity.ts Entity with automatic encryption/decryption of query_text field
backend/src/entities/visualizations/saved-db-query/saved-db-query.controller.ts REST API controller with 7 endpoints for query management
backend/src/entities/visualizations/saved-db-query/use-cases/*.ts Seven use cases implementing business logic for CRUD and execution
backend/src/entities/visualizations/saved-db-query/utils/check-query-is-safe.util.ts Security validation preventing destructive SQL operations
backend/src/entities/connection/connection.entity.ts Added relationship to saved queries
backend/src/common/application/global-database-context.ts Registered new repository in dependency injection
backend/src/exceptions/text/messages.ts Added SAVED_QUERY_NOT_FOUND message
backend/test/ava-tests/saas-tests/saved-database-queries-e2e.test.ts Comprehensive e2e tests (966 lines)
shared-code/src/data-access-layer/data-access-objects/*.ts Indentation reformatting (spaces → tabs)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -0,0 +1,966 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { faker } from '@faker-js/faker';
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

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

Unused import faker.

Copilot uses AI. Check for mistakes.
import request from 'supertest';
import { ApplicationModule } from '../../../src/app.module.js';
import { AllExceptionsFilter } from '../../../src/exceptions/all-exceptions.filter.js';
import { Messages } from '../../../src/exceptions/text/messages.js';
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

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

Unused import Messages.

Copilot uses AI. Check for mistakes.
test.serial(`${currentTest} should create a new saved query`, async (t) => {
const connectionToTestDB = getTestData(mockFactory).connectionToPostgres;
const firstUserToken = (await registerUserAndReturnUserInfo(app)).token;
const { testTableName, testTableColumnName, testTableSecondColumnName } = await createTestTable(connectionToTestDB);
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

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

Unused variable testTableColumnName.

Copilot uses AI. Check for mistakes.
test.serial(`${currentTest} should create a new saved query`, async (t) => {
const connectionToTestDB = getTestData(mockFactory).connectionToPostgres;
const firstUserToken = (await registerUserAndReturnUserInfo(app)).token;
const { testTableName, testTableColumnName, testTableSecondColumnName } = await createTestTable(connectionToTestDB);
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

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

Unused variable testTableSecondColumnName.

Copilot uses AI. Check for mistakes.
test.serial(`${currentTest} should execute a saved query and return results`, async (t) => {
const connectionToTestDB = getTestData(mockFactory).connectionToPostgres;
const firstUserToken = (await registerUserAndReturnUserInfo(app)).token;
const { testTableName, testTableColumnName, testTableSecondColumnName } = await createTestTable(connectionToTestDB);
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

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

Unused variable testTableColumnName.

Copilot uses AI. Check for mistakes.
test.serial(`${currentTest} should execute a saved query and return results`, async (t) => {
const connectionToTestDB = getTestData(mockFactory).connectionToPostgres;
const firstUserToken = (await registerUserAndReturnUserInfo(app)).token;
const { testTableName, testTableColumnName, testTableSecondColumnName } = await createTestTable(connectionToTestDB);
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

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

Unused variable testTableSecondColumnName.

Copilot uses AI. Check for mistakes.
return [];
}
if (connectionType === ConnectionTypesEnum.postgres || connectionType === ConnectionTypesEnum.agent_postgres) {
if (result && typeof result === 'object' && 'rows' in result) {
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

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

This use of variable 'result' always evaluates to true.

Suggested change
if (result && typeof result === 'object' && 'rows' in result) {
if (typeof result === 'object' && 'rows' in result) {

Copilot uses AI. Check for mistakes.
}

if (connectionType === ConnectionTypesEnum.postgres || connectionType === ConnectionTypesEnum.agent_postgres) {
if (result && typeof result === 'object' && 'rows' in result) {
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

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

This use of variable 'result' always evaluates to true.

Copilot uses AI. Check for mistakes.
@Artuomka Artuomka merged commit 1a66fe4 into main Jan 13, 2026
19 checks passed
@Artuomka Artuomka deleted the backend_dashboards branch January 13, 2026 14:18
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