Class PgColumn
java.lang.Object
org.pgcodekeeper.core.database.base.schema.AbstractStatement
org.pgcodekeeper.core.database.pg.schema.PgAbstractStatement
org.pgcodekeeper.core.database.pg.schema.PgColumn
- All Implemented Interfaces:
IColumn,IOptionContainer,ISearchPath,ISimpleOptionContainer,IStatement,ISubElement,ICompressOptionContainer,IHashable
public class PgColumn
extends PgAbstractStatement
implements ISimpleOptionContainer, ICompressOptionContainer, IColumn
PostgreSQL column implementation.
Stores column information including data type, constraints, storage parameters,
statistics, compression settings, and identity properties.
-
Field Summary
Fields inherited from interface org.pgcodekeeper.core.database.pg.schema.ICompressOptionContainer
DEFAULT_BLOCK_SIZE, DEFAULT_COMPRESS_LEVEL, DEFAULT_COMPRESS_TYPE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddForeignOption(String attribute, String value) Adds a foreign table option to this column.voidAdds an option to this container.appendAlterSQL(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.voidgetCreationSQL(SQLScript script) Generates the SQL statements needed to create this database object.voidgetDropSQL(SQLScript script, boolean optionExists) Generates DROP SQL for this statement.Gets all options for this container.Returns the parent column for given column or null if given column hasn't parent column.getType()booleanbooleanbooleanisJoinable(PgColumn newColumn) Checks if this column can be joined with another column in a single ALTER statement.booleanvoidjoinAction(StringBuilder sb, PgColumn newColumn, boolean isNeedAlterTable, boolean isLastColumn, ISettings settings) Generates SQL for joining column changes in a single ALTER statement.voidsetBlockSize(int blockSize) Sets the block size for this object.voidsetCollation(String collation) voidsetCompression(String compression) voidsetCompressLevel(int compressLevel) Sets the compression level for this object.voidsetCompressType(String compressType) Sets the compression type for this object.voidsetDefaultValue(String defaultValue) voidsetGenerationOption(String generationOption) voidsetIdentityType(String identityType) voidsetInherit(boolean isInherit) voidsetNotNullConstraint(PgConstraintNotNull notNullConstraint) voidsetSequence(PgSequence sequence) voidsetStatistics(Integer statistics) voidsetStorage(String storage) voidMethods 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, 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.IColumn
getStatementTypeMethods inherited from interface org.pgcodekeeper.core.database.api.schema.ISearchPath
getDatabase, getSchemaNameMethods inherited from interface org.pgcodekeeper.core.database.api.schema.ISimpleOptionContainer
appendOptions, compareOptionsMethods inherited from interface org.pgcodekeeper.core.database.api.schema.IStatement
addDependency, appendOwnerSQL, canDrop, canDropBeforeCreate, clearPrivileges, deepCopy, formatSql, getAuthor, getBareName, getChildren, getComment, getDependencies, getDescendants, getLibName, getLocation, getName, getOwner, getParent, getPrivileges, getQualifiedName, getQuotedName, getQuoter, getRenameCommand, getSeparator, getSQL, getTwin, getTypeName, hasChildren, isLib, isOwned, quote, setComment, setLibName, setLocation, setOwner, shallowCopyMethods inherited from interface org.pgcodekeeper.core.database.api.schema.ISubElement
getContainingSchema, toObjectReference
-
Constructor Details
-
PgColumn
Creates a new PostgreSQL column.- Parameters:
name- column name
-
-
Method Details
-
getFullDefinition
-
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
-
getDropSQL
Description copied from interface:IStatementGenerates DROP SQL for this statement.- Specified by:
getDropSQLin interfaceIStatement- Overrides:
getDropSQLin classAbstractStatement- Parameters:
script- the SQL script to append the DROP statement tooptionExists- whether to include "IF EXISTS" in the DROP statement
-
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
-
isJoinable
Checks if this column can be joined with another column in a single ALTER statement.- Parameters:
newColumn- column to compare with- Returns:
- true if columns can be joined in one ALTER statement
-
joinAction
public void joinAction(StringBuilder sb, PgColumn newColumn, boolean isNeedAlterTable, boolean isLastColumn, ISettings settings) Generates SQL for joining column changes in a single ALTER statement.- Parameters:
sb- StringBuilder to append SQL tonewColumn- new column stateisNeedAlterTable- whether to include ALTER TABLE prefixisLastColumn- whether this is the last column in a multi-column ALTERsettings- generation settings
-
getParentCol
Returns the parent column for given column or null if given column hasn't parent column.- Parameters:
tbl- table to search inheritance hierarchy from- Returns:
- parent column or null if no parent column exists
-
getOptions
Description copied from interface:IOptionContainerGets all options for this container.- Specified by:
getOptionsin interfaceIOptionContainer- Returns:
- a map of option keys to values
-
addOption
Description copied from interface:IOptionContainerAdds an option to this container.- Specified by:
addOptionin interfaceIOptionContainer- Parameters:
attribute- the option keyvalue- the option value
-
getForeignOptions
-
addForeignOption
Adds a foreign table option to this column.- Parameters:
attribute- option namevalue- option value
-
setCompressType
Description copied from interface:ICompressOptionContainerSets the compression type for this object.- Specified by:
setCompressTypein interfaceICompressOptionContainer- Parameters:
compressType- the compression type to set
-
setCompressLevel
public void setCompressLevel(int compressLevel) Description copied from interface:ICompressOptionContainerSets the compression level for this object.- Specified by:
setCompressLevelin interfaceICompressOptionContainer- Parameters:
compressLevel- the compression level to set
-
setBlockSize
public void setBlockSize(int blockSize) Description copied from interface:ICompressOptionContainerSets the block size for this object.- Specified by:
setBlockSizein interfaceICompressOptionContainer- Parameters:
blockSize- the block size to set
-
isInherit
public boolean isInherit() -
setInherit
public void setInherit(boolean isInherit) -
isNotNull
public boolean isNotNull() -
isGenerated
public boolean isGenerated() -
setGenerationOption
-
setStatistics
-
getStatistics
-
getStorage
-
setStorage
-
getSequence
-
setSequence
-
setIdentityType
-
getIdentityType
-
setCompression
-
getNotNullConstraint
-
setNotNullConstraint
-
setDefaultValue
-
getDefaultValue
-
setType
-
getType
-
setCollation
-
getCollation
-
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
-