Class PgRule

java.lang.Object
org.pgcodekeeper.core.schema.PgStatement
org.pgcodekeeper.core.schema.pg.PgRule
All Implemented Interfaces:
IHashable, ISearchPath, IStatement

public final class PgRule extends PgStatement implements ISearchPath
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.
  • Constructor Details

    • PgRule

      public PgRule(String name)
      Creates a new PostgreSQL rule.
      Parameters:
      name - rule name
  • Method Details

    • getStatementType

      public DbObjType getStatementType()
      Description copied from interface: IStatement
      Gets the type of this database object.
      Specified by:
      getStatementType in interface IStatement
      Returns:
      the database object type
    • setEvent

      public void setEvent(EventType event)
    • setCondition

      public void setCondition(String condition)
    • setInstead

      public void setInstead(boolean instead)
    • addCommand

      public void addCommand(String command)
      Adds an action command to be executed when this rule fires.
      Parameters:
      command - SQL command to execute
    • setEnabledState

      public void setEnabledState(String enabledState)
    • getCreationSQL

      public void getCreationSQL(SQLScript script)
      Description copied from class: PgStatement
      Generates 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:
      getCreationSQL in class PgStatement
      Parameters:
      script - the SQL script to append creation statements to
    • appendAlterSQL

      public ObjectState appendAlterSQL(PgStatement newCondition, SQLScript script)
      Description copied from class: PgStatement
      Fill script with object changes and return change type
      Specified by:
      appendAlterSQL in class PgStatement
      Parameters:
      newCondition - new object state
      script - script to collect changes
      Returns:
      object change type
    • canDropBeforeCreate

      public boolean canDropBeforeCreate()
      Description copied from class: PgStatement
      Checks if this statement can be dropped before being recreated. Override in subclasses that support drop-before-create behavior.
      Overrides:
      canDropBeforeCreate in class PgStatement
      Returns:
      true if the statement can be dropped before recreation
    • shallowCopy

      public PgRule shallowCopy()
      Description copied from class: PgStatement
      Copies all object properties into a new object and leaves all its children empty.
      Specified by:
      shallowCopy in class PgStatement
      Returns:
      shallow copy of a DB object.
    • compare

      public boolean compare(PgStatement obj)
      Description copied from class: PgStatement
      This method does not account for nested child PgStatements. Shallow version of PgStatement.equals(Object)
      Overrides:
      compare in class PgStatement
    • computeHash

      public void computeHash(Hasher hasher)
      Description copied from interface: IHashable
      Computes the hash of the implementing object using the provided hasher. The implementation should call appropriate put methods on the hasher for all fields that should contribute to the hash value.
      Specified by:
      computeHash in interface IHashable
      Parameters:
      hasher - the hasher instance to use for hash computation
    • getContainingSchema

      public AbstractSchema getContainingSchema()
      Description copied from interface: ISearchPath
      Gets the schema that contains this object.
      Specified by:
      getContainingSchema in interface ISearchPath
      Returns:
      the containing schema
    • isSubElement

      public boolean isSubElement()
      Description copied from class: PgStatement
      Checks if this statement is a sub-element of another statement.
      Overrides:
      isSubElement in class PgStatement
      Returns:
      true if this is a sub-element