Class PgAbstractView

All Implemented Interfaces:
IOptionContainer, IRelation, ISearchPath, ISimpleOptionContainer, IStatement, IStatementContainer, IView, IHashable
Direct Known Subclasses:
PgMaterializedView, PgView

public abstract class PgAbstractView extends PgAbstractStatementContainer implements IView, ISimpleOptionContainer
Base PostgreSQL view implementation. Provides common functionality for PostgreSQL views including query handling, column comments, view options, and default values management.
Author:
fordfrog
  • Field Details

  • Method Details

    • getCreationSQL

      public void getCreationSQL(SQLScript script)
      Description copied from interface: IStatement
      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 interface IStatement
      Parameters:
      script - the SQL script to append creation statements to
    • appendComments

      public void appendComments(SQLScript script)
      Description copied from class: AbstractStatement
      Appends comment SQL to the script if this statement has comments.
      Overrides:
      appendComments in class AbstractStatement
      Parameters:
      script - the SQL script to append comments to
    • appendAlterSQL

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

      public void appendAlterComments(AbstractStatement newObj, SQLScript script)
      Description copied from class: AbstractStatement
      Appends ALTER comment SQL if the comment has changed.
      Overrides:
      appendAlterComments in class AbstractStatement
      Parameters:
      newObj - the new statement to compare comments with
      script - the SQL script to append ALTER comments to
    • canDropBeforeCreate

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

      public void addColumnName(String colName)
      Adds a column name to this view.
      Parameters:
      colName - column name to add
    • setQuery

      public void setQuery(String query, String normalizedQuery)
      Sets the view query and its normalized form.
      Parameters:
      query - original query text
      normalizedQuery - normalized query for comparison
    • getOptions

      public Map<String,String> getOptions()
      Description copied from interface: IOptionContainer
      Gets all options for this container.
      Specified by:
      getOptions in interface IOptionContainer
      Returns:
      a map of option keys to values
    • addOption

      public void addOption(String option, String value)
      Description copied from interface: IOptionContainer
      Adds an option to this container.
      Specified by:
      addOption in interface IOptionContainer
      Parameters:
      option - the option key
      value - the option value
    • addColumnComment

      public void addColumnComment(String columnName, String comment)
      Adds a comment to a view column.
      Parameters:
      columnName - column name
      comment - comment text (ignored if null or empty)
    • getRelationColumns

      public Stream<Pair<String,String>> getRelationColumns()
      Description copied from interface: IRelation
      Gets the columns of this relation as name-type pairs.
      Specified by:
      getRelationColumns in interface IRelation
      Returns:
      a stream of column name and type pairs
    • 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
    • getConstraints

      public Collection<IConstraint> getConstraints()
      Specified by:
      getConstraints in class PgAbstractStatementContainer
    • compare

      public boolean compare(IStatement obj)
      Description copied from class: AbstractStatement
      This method does not account for nested child PgStatements. Shallow version of AbstractStatement.equals(Object)
      Specified by:
      compare in interface IStatement
      Overrides:
      compare in class AbstractStatement