Package org.pgcodekeeper.core.schema.pg
Class PgRule
java.lang.Object
org.pgcodekeeper.core.schema.PgStatement
org.pgcodekeeper.core.schema.pg.PgRule
- All Implemented Interfaces:
IHashable,ISearchPath,IStatement
PostgreSQL table rule implementation.
Rules define actions to be performed when certain operations (INSERT, UPDATE, DELETE)
are executed on a table, effectively implementing view-like behavior and query rewriting.
-
Field Summary
Fields inherited from class org.pgcodekeeper.core.schema.PgStatement
GO -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCommand(String command) Adds an action command to be executed when this rule fires.appendAlterSQL(PgStatement newCondition, SQLScript script) Fill script with object changes and return change typebooleanChecks 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.Gets the schema that contains this object.voidgetCreationSQL(SQLScript script) Generates the SQL statements needed to create this database object.Gets the type of this database object.booleanChecks if this statement is a sub-element of another statement.voidsetCondition(String condition) voidsetEnabledState(String enabledState) voidvoidsetInstead(boolean instead) Copies all object properties into a new object and leaves all its children empty.Methods inherited from class org.pgcodekeeper.core.schema.PgStatement
addAllDeps, addDep, addPrivilege, appendAlterComments, appendComments, appendOwnerSQL, canDrop, 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, 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
-
PgRule
Creates a new PostgreSQL rule.- Parameters:
name- rule name
-
-
Method Details
-
getStatementType
Description copied from interface:IStatementGets the type of this database object.- Specified by:
getStatementTypein interfaceIStatement- Returns:
- the database object type
-
setEvent
-
setCondition
-
setInstead
public void setInstead(boolean instead) -
addCommand
Adds an action command to be executed when this rule fires.- Parameters:
command- SQL command to execute
-
setEnabledState
-
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
-
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
-
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
-
shallowCopy
Description copied from class:PgStatementCopies all object properties into a new object and leaves all its children empty.- Specified by:
shallowCopyin classPgStatement- Returns:
- shallow copy of a DB object.
-
compare
Description copied from class:PgStatementThis method does not account for nested child PgStatements. Shallow version ofPgStatement.equals(Object)- Overrides:
comparein classPgStatement
-
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
-
getContainingSchema
Description copied from interface:ISearchPathGets the schema that contains this object.- Specified by:
getContainingSchemain interfaceISearchPath- Returns:
- the containing schema
-
isSubElement
public boolean isSubElement()Description copied from class:PgStatementChecks if this statement is a sub-element of another statement.- Overrides:
isSubElementin classPgStatement- Returns:
- true if this is a sub-element
-