mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-07-31 19:52:54 +08:00
feat(PostgreSQL): delete the PostgreSQL sequences
This commit is contained in:
@ -22,6 +22,9 @@ import java.util.stream.Collectors;
|
||||
|
||||
import static ai.chat2db.plugin.postgresql.consts.SequenceCommonConst.*;
|
||||
import static ai.chat2db.plugin.postgresql.consts.SQLConst.*;
|
||||
import static ai.chat2db.server.tools.base.constant.SymbolConstant.*;
|
||||
import static ai.chat2db.server.tools.base.constant.SymbolConstant.DOT;
|
||||
import static ai.chat2db.server.tools.base.constant.SymbolConstant.SEMICOLON;
|
||||
import static ai.chat2db.spi.util.SortUtils.sortDatabase;
|
||||
|
||||
public class PostgreSQLMetaData extends DefaultMetaService implements MetaData {
|
||||
@ -369,7 +372,7 @@ public class PostgreSQLMetaData extends DefaultMetaService implements MetaData {
|
||||
|
||||
Optional.ofNullable(comment).ifPresent(v -> stringBuilder.append(COMMENT_ON_SEQUENCE)
|
||||
.append(nspname).append(DOT).append(relname)
|
||||
.append(IS).append(SINGLE_QUOTE).append(comment).append(SINGLE_QUOTE).append(SEMICOLON).append(BLANK_LINE));
|
||||
.append(IS).append(SQUOT).append(comment).append(SQUOT).append(SEMICOLON).append(BLANK_LINE));
|
||||
|
||||
Optional.ofNullable(rolname).ifPresent(v -> stringBuilder.append(ALTER_SEQUENCE)
|
||||
.append(nspname).append(DOT).append(relname)
|
||||
|
@ -17,6 +17,10 @@ import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static ai.chat2db.plugin.postgresql.consts.SequenceCommonConst.*;
|
||||
import static ai.chat2db.server.tools.base.constant.SymbolConstant.BLANK_LINE;
|
||||
import static ai.chat2db.server.tools.base.constant.SymbolConstant.SQUOT;
|
||||
import static ai.chat2db.server.tools.base.constant.SymbolConstant.DOT;
|
||||
import static ai.chat2db.server.tools.base.constant.SymbolConstant.SEMICOLON;
|
||||
|
||||
|
||||
public class PostgreSQLSqlBuilder extends DefaultSqlBuilder {
|
||||
@ -282,7 +286,7 @@ public class PostgreSQLSqlBuilder extends DefaultSqlBuilder {
|
||||
sqlBuilder.append(ALTER_SEQUENCE).append(oldSequence.getNspname()).append(DOT).append(oldSequence.getRelname()).append(RENAME_TO).append(newSequence.getRelname()).append(SEMICOLON).append(BLANK_LINE);
|
||||
}
|
||||
if (!StringUtils.equals(oldSequence.getComment(), newSequence.getComment())) {
|
||||
sqlBuilder.append(COMMENT_ON_SEQUENCE).append(newSequence.getNspname()).append(DOT).append(newSequence.getRelname()).append(IS).append(SINGLE_QUOTE).append(newSequence.getComment()).append(SINGLE_QUOTE).append(SEMICOLON).append(BLANK_LINE);
|
||||
sqlBuilder.append(COMMENT_ON_SEQUENCE).append(newSequence.getNspname()).append(DOT).append(newSequence.getRelname()).append(IS).append(SQUOT).append(newSequence.getComment()).append(SQUOT).append(SEMICOLON).append(BLANK_LINE);
|
||||
}
|
||||
if (!StringUtils.equals(oldSequence.getSeqcache(), newSequence.getSeqcache())) {
|
||||
sqlBuilder.append(ALTER_SEQUENCE).append(newSequence.getNspname()).append(DOT).append(newSequence.getRelname()).append(CACHE).append(newSequence.getSeqcache()).append(SEMICOLON).append(BLANK_LINE);
|
||||
|
@ -27,9 +27,4 @@ public class SequenceCommonConst {
|
||||
public static final String OWNED_BY = " OWNED BY ";
|
||||
public static final String IS = " IS ";
|
||||
public static final String AS = " AS ";
|
||||
public static final String BLANK_LINE = "\n\n";
|
||||
public static final String NEW_LINE = "\n";
|
||||
public static final String SEMICOLON = ";";
|
||||
public static final String DOT = ".";
|
||||
public static final String SINGLE_QUOTE = "'";
|
||||
}
|
||||
|
Reference in New Issue
Block a user