Package org.pgcodekeeper.core.schema.pg
Class PgSequence
java.lang.Object
org.pgcodekeeper.core.schema.PgStatement
org.pgcodekeeper.core.schema.AbstractSequence
org.pgcodekeeper.core.schema.pg.PgSequence
- All Implemented Interfaces:
IHashable,IRelation,ISearchPath,IStatement
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.
-
Field Summary
Fields inherited from class org.pgcodekeeper.core.schema.PgStatement
GO -
Constructor Summary
ConstructorsConstructorDescriptionPgSequence(String name) Creates a new PostgreSQL sequence with default cache value of 1. -
Method Summary
Modifier and TypeMethodDescriptionappendAlterSQL(PgStatement newCondition, SQLScript script) Fill script with object changes and return change typebooleancompare(PgStatement 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) Fills the sequence body SQL definition.voidgetCreationSQL(SQLScript script) Generates the SQL statements needed to create this database object.Gets the table column that owns this sequence.booleanisLogged()Checks if this sequence is logged (written to WAL).voidsetDataType(String dataType) voidsetLogged(boolean isLogged) voidsetMinMaxInc(long inc, Long max, Long min, String dataType, long precision) Sets the minimum, maximum, and increment values for this sequence.voidsetOwnedBy(GenericColumn ownedBy) Copies all object properties into a new object and leaves all its children empty.Methods inherited from class org.pgcodekeeper.core.schema.AbstractSequence
getContainingSchema, getDataType, getRelationColumns, getStatementType, setCache, setCycle, setStartWithMethods inherited from class org.pgcodekeeper.core.schema.PgStatement
addAllDeps, addDep, addPrivilege, appendAlterComments, appendComments, appendOwnerSQL, canDrop, canDropBeforeCreate, checkComments, clearPrivileges, compareChildren, deepCopy, equals, getAuthor, getBareName, getChildren, getComment, getDbType, getDeps, getDescendants, getDropSQL, getDropSQL, getLibName, getLocation, getName, getObjectState, getObjectState, getOwner, getParent, getPrivileges, getQualifiedName, getSQL, getTwin, getTypeName, hasChildren, hashCode, isLib, isOwned, isSubElement, setAuthor, setComment, setLibName, setLocation, setOwner, setParent, toStringMethods inherited from interface org.pgcodekeeper.core.schema.ISearchPath
getDatabase, getSchemaNameMethods inherited from interface org.pgcodekeeper.core.schema.IStatement
getBareName, getComment, getName, getParent, getQualifiedName
-
Constructor Details
-
PgSequence
Creates a new PostgreSQL sequence with default cache value of 1.- Parameters:
name- sequence name
-
-
Method Details
-
getCreationSQL
Description copied from class:PgStatementGenerates 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 classPgStatement- Parameters:
script- the SQL script to append creation statements to
-
fillSequenceBody
Description copied from class:AbstractSequenceFills the sequence body SQL definition.- Specified by:
fillSequenceBodyin classAbstractSequence- Parameters:
sbSQL- the StringBuilder to append the sequence body to
-
appendAlterSQL
Description copied from class:PgStatementFill script with object changes and return change type- Specified by:
appendAlterSQLin classPgStatement- Parameters:
newCondition- new object statescript- script to collect changes- Returns:
- object change type
-
setMinMaxInc
Description copied from class:AbstractSequenceSets the minimum, maximum, and increment values for this sequence.- Specified by:
setMinMaxIncin classAbstractSequence- Parameters:
inc- the increment valuemax- the maximum valuemin- the minimum valuedataType- the data type of the sequenceprecision- the precision for numeric types
-
compare
Description copied from class:PgStatementThis method does not account for nested child PgStatements. Shallow version ofPgStatement.equals(Object)- Overrides:
comparein classAbstractSequence
-
getOwnedBy
Gets the table column that owns this sequence.- Returns:
- column reference or null if not owned
-
setOwnedBy
-
setDataType
- Overrides:
setDataTypein classAbstractSequence
-
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) -
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- Overrides:
computeHashin classAbstractSequence- Parameters:
hasher- the hasher instance to use for hash computation
-
shallowCopy
Description copied from class:PgStatementCopies all object properties into a new object and leaves all its children empty.- Overrides:
shallowCopyin classAbstractSequence- Returns:
- shallow copy of a DB object.
-