-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Added sequence for pgsql #1734
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
Added sequence for pgsql #1734
Conversation
…etailQueryRequest
…Greyrat/Chat2DB into feet_postresql_sequences
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 PR adds support for sequence operations (CRUD, DDL export, and SQL generation) across the backend SPI, PostgreSQL plugin, domain services, and the frontend UI.
- Introduce new
SequenceandSimpleSequencemodels and extendSqlBuilder,MetaData, andDBManageinterfaces for sequences. - Implement PostgreSQL-specific SQL builder and metadata retrieval for sequences.
- Wire up new sequence endpoints and UI components (tree context menu, editor, console integration, i18n, typings).
Reviewed Changes
Copilot reviewed 73 out of 73 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| SQLExecutor.java | Added generic preExecute helper for querying. |
| DefaultSqlBuilder.java & SqlBuilder.java | Added stub methods for buildCreateSequenceSql and buildModifySequenceSql. |
| DefaultMetaService.java & PostgreSQLMetaData.java | Extended sequence DDL and listing logic. |
| PostgreSQLSqlBuilder.java | Implemented SQL generation for sequences. |
| Frontend (service/sql.ts, deleteSequence.tsx, SequenceEditor, treeConfig, workspace store, etc.) | Hooked up new sequence UI flows and APIs. |
Comments suppressed due to low confidence (2)
chat2db-server/chat2db-spi/src/main/java/ai/chat2db/spi/model/SimpleSequence.java:3
- [nitpick] The class uses
SimpleSequencebut the SPI interface method is calledsequences. Consider consistent naming of methods (simpleSequences) or models to avoid confusion.
import lombok.AllArgsConstructor;
chat2db-client/src/service/sql.ts:62
- Overloading
ITableParamswith a capitalizedNameprop for sequence operations conflicts with existingtableNameusage and backend expectations (sequenceName). Define dedicated request interfaces for sequence endpoints (e.g.,ISequenceParams).
}
| import ai.chat2db.spi.util.JdbcUtils; | ||
| import ai.chat2db.spi.util.ResultSetUtils; | ||
| import ai.chat2db.spi.util.SqlUtils; | ||
| import cn.hutool.core.collection.CollectionUtil; |
Copilot
AI
Jul 10, 2025
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.
The import of CollectionUtil is unused in this class. Consider removing it to reduce clutter.
| import cn.hutool.core.collection.CollectionUtil; |
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public String buildModifySequenceSql(Sequence oldSequence, Sequence newSequence) { | ||
| return null; |
Copilot
AI
Jul 10, 2025
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.
Returning null from these stub methods will lead to NPEs when sequence SQL is generated. Either throw UnsupportedOperationException or provide a default implementation.
| return null; | |
| } | |
| @Override | |
| public String buildModifySequenceSql(Sequence oldSequence, Sequence newSequence) { | |
| return null; | |
| throw new UnsupportedOperationException("buildCreateSequenceSql is not implemented yet."); | |
| } | |
| @Override | |
| public String buildModifySequenceSql(Sequence oldSequence, Sequence newSequence) { | |
| throw new UnsupportedOperationException("buildModifySequenceSql is not implemented yet."); |
| dataSourceId: treeNodeData.extraParams.dataSourceId, | ||
| databaseName: treeNodeData.extraParams.databaseName, | ||
| schemaName: treeNodeData.extraParams.schemaName, | ||
| tableName: treeNodeData.name, |
Copilot
AI
Jul 10, 2025
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.
Payload includes both tableName and sequenceName but the service (bound to ITableParams) expects Name or sequenceName. Align the request payload with the service signature or use a dedicated sequence delete interface.
| tableName: treeNodeData.name, |
#1733