-
-
Notifications
You must be signed in to change notification settings - Fork 18
added saved queries module and functional #1498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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'; | |||
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused import faker.
| 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'; |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused import Messages.
| 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); |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused variable testTableColumnName.
| 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); |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused variable testTableSecondColumnName.
| 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); |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused variable testTableColumnName.
| 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); |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused variable testTableSecondColumnName.
| return []; | ||
| } | ||
| if (connectionType === ConnectionTypesEnum.postgres || connectionType === ConnectionTypesEnum.agent_postgres) { | ||
| if (result && typeof result === 'object' && 'rows' in result) { |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
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.
| if (result && typeof result === 'object' && 'rows' in result) { | |
| if (typeof result === 'object' && 'rows' in result) { |
| } | ||
|
|
||
| if (connectionType === ConnectionTypesEnum.postgres || connectionType === ConnectionTypesEnum.agent_postgres) { | ||
| if (result && typeof result === 'object' && 'rows' in result) { |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
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.
No description provided.