Class PgSequence
java.lang.Object
org.pgcodekeeper.core.database.base.schema.AbstractStatement
org.pgcodekeeper.core.database.pg.schema.PgAbstractStatement
org.pgcodekeeper.core.database.pg.schema.PgSequence
- All Implemented Interfaces:
IRelation,ISearchPath,ISequence,IStatement,IHashable
PostgreSQL sequence implementation.
Sequences generate unique numeric identifiers, commonly used for auto-incrementing primary keys.
Supports various data types, caching, cycling, and ownership by table columns.
-
Constructor Summary
ConstructorsConstructorDescriptionPgSequence(String name) Creates a new PostgreSQL sequence with default cache value of 1. -
Method Summary
Modifier and TypeMethodDescriptionappendAlterSQL(IStatement newCondition, SQLScript script) Fill script with object changes and return change typebooleancompare(IStatement obj) This method does not account for nested child PgStatements.voidcomputeHash(Hasher hasher) Computes the hash of the implementing object using the provided hasher.voidfillSequenceBody(StringBuilder sbSQL) voidgetCreationSQL(SQLScript script) Generates the SQL statements needed to create this database object.Gets the table column that owns this sequence.voidgetOwnedBySQL(SQLScript script) Creates SQL statement for modification "OWNED BY" parameter.voidgetOwnedBySQL(SQLScript script, SQLActionType type) Gets the columns of this relation as name-type pairs.booleanisLogged()Checks if this sequence is logged (written to WAL).voidvoidsetCycle(boolean cycle) voidsetDataType(String dataType) voidsetLogged(boolean isLogged) voidsetMinMaxInc(long inc, Long max, Long min, String dataType, long precision) voidsetOwnedBy(ObjectReference ownedBy) voidsetStartWith(String startWith) Methods inherited from class org.pgcodekeeper.core.database.pg.schema.PgAbstractStatement
addPrivilege, appendDefaultPrivileges, appendOwnerSQL, formatSql, getQuoter, getRenameCommand, isOwnedMethods inherited from class org.pgcodekeeper.core.database.base.schema.AbstractStatement
addDependency, appendAlterComments, appendComments, appendPrivileges, canDrop, canDropBeforeCreate, checkComments, clearPrivileges, compareChildren, deepCopy, equals, fillChildrenList, fillDescendantsList, getAuthor, getBareName, getChildren, getComment, getDependencies, getDescendants, getDropSQL, getDropSQL, getLibName, getLocation, getName, getObjectState, getObjectState, getOwner, getParent, getPrivileges, getQualifiedName, getSeparator, getSQL, getTwin, hasChildren, hashCode, isLib, setAuthor, setComment, setLibName, setLocation, setOwner, setParent, shallowCopy, toStringMethods inherited from interface org.pgcodekeeper.core.database.api.schema.ISearchPath
getContainingSchema, getDatabase, getSchemaName, toObjectReferenceMethods inherited from interface org.pgcodekeeper.core.database.api.schema.ISequence
getStatementTypeMethods inherited from interface org.pgcodekeeper.core.database.api.schema.IStatement
addDependency, appendOwnerSQL, canDrop, canDropBeforeCreate, clearPrivileges, deepCopy, formatSql, getAuthor, getBareName, getChildren, getComment, getDependencies, getDescendants, getDropSQL, getLibName, getLocation, getName, getOwner, getParent, getPrivileges, getQualifiedName, getQuotedName, getQuoter, getRenameCommand, getSeparator, getSQL, getTwin, getTypeName, hasChildren, isLib, isOwned, quote, setComment, setLibName, setLocation, setOwner, shallowCopy
-
Constructor Details
-
PgSequence
Creates a new PostgreSQL sequence with default cache value of 1.- Parameters:
name- sequence name
-
-
Method Details
-
getCreationSQL
Description copied from interface:IStatementGenerates the SQL statements needed to create this database object. This is an abstract method that must be implemented by subclasses to provide the specific CREATE SQL for each object type.- Specified by:
getCreationSQLin interfaceIStatement- Parameters:
script- the SQL script to append creation statements to
-
fillSequenceBody
-
getOwnedBySQL
Creates SQL statement for modification "OWNED BY" parameter. -
getOwnedBySQL
-
appendAlterSQL
Description copied from interface:IStatementFill script with object changes and return change type- Specified by:
appendAlterSQLin interfaceIStatement- Parameters:
newCondition- new object statescript- script to collect changes- Returns:
- object change type
-
setMinMaxInc
-
setStartWith
-
getOwnedBy
Gets the table column that owns this sequence.- Returns:
- column reference or null if not owned
-
setOwnedBy
-
setDataType
-
getDataType
-
isLogged
public boolean isLogged()Checks if this sequence is logged (written to WAL).- Returns:
- true if logged, false if unlogged
-
setLogged
public void setLogged(boolean isLogged) -
setCycle
public void setCycle(boolean cycle) -
setCache
-
getRelationColumns
Description copied from interface:IRelationGets the columns of this relation as name-type pairs.- Specified by:
getRelationColumnsin interfaceIRelation- Returns:
- a stream of column name and type pairs
-
computeHash
Description copied from interface:IHashableComputes the hash of the implementing object using the provided hasher. The implementation should call appropriateputmethods on the hasher for all fields that should contribute to the hash value.- Specified by:
computeHashin interfaceIHashable- Parameters:
hasher- the hasher instance to use for hash computation
-
compare
Description copied from class:AbstractStatementThis method does not account for nested child PgStatements. Shallow version ofAbstractStatement.equals(Object)- Specified by:
comparein interfaceIStatement- Overrides:
comparein classAbstractStatement
-