Package org.pgcodekeeper.core.schema.pg
Class AbstractPgView
java.lang.Object
org.pgcodekeeper.core.schema.PgStatement
org.pgcodekeeper.core.schema.PgStatementContainer
org.pgcodekeeper.core.schema.AbstractView
org.pgcodekeeper.core.schema.pg.AbstractPgView
- All Implemented Interfaces:
IHashable,IOptionContainer,IRelation,ISearchPath,ISimpleOptionContainer,IStatement,IStatementContainer
- Direct Known Subclasses:
MaterializedPgView,PgView
Base PostgreSQL view implementation.
Provides common functionality for PostgreSQL views including query handling,
column comments, view options, and default values management.
- Author:
- fordfrog
-
Field Summary
FieldsFields inherited from class org.pgcodekeeper.core.schema.PgStatement
GOFields inherited from interface org.pgcodekeeper.core.schema.IOptionContainer
GP_OPTION_LIST -
Method Summary
Modifier and TypeMethodDescriptionvoidaddColumnComment(String columnName, String comment) Adds a comment to a view column.voidaddColumnName(String colName) Adds a column name to this view.voidAdds an option to this container.voidappendAlterComments(PgStatement newObj, SQLScript script) Appends ALTER comment SQL if the comment has changed.appendAlterSQL(PgStatement newCondition, SQLScript script) Fill script with object changes and return change typevoidappendComments(SQLScript script) Appends comment SQL to the script if this statement has comments.booleanChecks if this statement can be dropped before being recreated.booleancompare(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.voidgetCreationSQL(SQLScript script) Generates the SQL statements needed to create this database object.Gets all options for this container.Gets the columns of this relation as name-type pairs.voidSets the view query and its normalized form.Methods inherited from class org.pgcodekeeper.core.schema.AbstractView
addConstraint, getConstraint, getConstraints, getStatementTypeMethods inherited from class org.pgcodekeeper.core.schema.PgStatementContainer
addChild, addIndex, addPolicy, addRule, addTrigger, compareChildren, computeChildrenHash, getChild, getContainingSchema, getIndex, getIndexes, getPolicies, getPolicy, getRule, getRules, getTrigger, getTriggers, isClustered, shallowCopyMethods inherited from class org.pgcodekeeper.core.schema.PgStatement
addAllDeps, addDep, addPrivilege, appendOwnerSQL, canDrop, checkComments, clearPrivileges, 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.ISimpleOptionContainer
appendOptions, compareOptionsMethods inherited from interface org.pgcodekeeper.core.schema.IStatement
getBareName, getComment, getName, getParent, getQualifiedName, getStatementType
-
Field Details
-
CHECK_OPTION
- See Also:
-
-
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
-
appendComments
Description copied from class:PgStatementAppends comment SQL to the script if this statement has comments.- Overrides:
appendCommentsin classPgStatement- Parameters:
script- the SQL script to append comments 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
-
appendAlterComments
Description copied from class:PgStatementAppends ALTER comment SQL if the comment has changed.- Overrides:
appendAlterCommentsin classPgStatement- Parameters:
newObj- the new statement to compare comments withscript- the SQL script to append ALTER comments to
-
canDropBeforeCreate
public boolean canDropBeforeCreate()Description copied from class:PgStatementChecks if this statement can be dropped before being recreated. Override in subclasses that support drop-before-create behavior.- Overrides:
canDropBeforeCreatein classPgStatement- Returns:
- true if the statement can be dropped before recreation
-
addColumnName
Adds a column name to this view.- Parameters:
colName- column name to add
-
setQuery
Sets the view query and its normalized form.- Parameters:
query- original query textnormalizedQuery- normalized query for comparison
-
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:
option- the option keyvalue- the option value
-
addColumnComment
Adds a comment to a view column.- Parameters:
columnName- column namecomment- comment text (ignored if null or empty)
-
getRelationColumns
Description copied from interface:IRelationGets the columns of this relation as name-type pairs.- Specified by:
getRelationColumnsin interfaceIRelation- Overrides:
getRelationColumnsin classAbstractView- Returns:
- a stream of column name and type pairs
-
compare
Description copied from class:PgStatementThis method does not account for nested child PgStatements. Shallow version ofPgStatement.equals(Object)- Overrides:
comparein classAbstractView
-
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
-