Class MsConstraintPk
java.lang.Object
org.pgcodekeeper.core.database.base.schema.AbstractStatement
org.pgcodekeeper.core.database.ms.schema.MsAbstractStatement
org.pgcodekeeper.core.database.ms.schema.MsConstraint
org.pgcodekeeper.core.database.ms.schema.MsConstraintPk
- All Implemented Interfaces:
IConstraint,IConstraintPk,IOptionContainer,ISearchPath,ISimpleColumnContainer,IStatement,ISubElement,IHashable
public class MsConstraintPk
extends MsConstraint
implements IConstraintPk, IOptionContainer, ISimpleColumnContainer
Represents a Microsoft SQL PRIMARY KEY or UNIQUE constraint.
Supports both clustered and non-clustered indexes with various options.
-
Constructor Summary
ConstructorsConstructorDescriptionMsConstraintPk(String name, boolean isPrimaryKey) Creates a new Microsoft SQL PRIMARY KEY or UNIQUE constraint. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddColumn(SimpleColumn column) Adds a column reference to this container.voidaddInclude(String column) Throws an exception as include columns are not supported for primary key/unique constraints.voidAdds an option to this container.booleancompare(IStatement obj) This method does not account for nested child PgStatements.voidcompareOptions(IOptionContainer newContainer, SQLScript script) Compares options between this container and a new container, generating SQL to update differences.voidcomputeHash(Hasher hasher) Computes the hash of the implementing object using the provided hasher.booleancontainsColumn(String name) Checks if this constraint involves the specified column.Gets the columns involved in this constraint.Gets the SQL definition of this constraint.Gets all options for this container.booleanChecks if this primary key constraint is clustered.booleanChecks if this constraint is a primary key constraint.voidsetClustered(boolean isClustered) voidsetDataSpace(String dataSpace) Methods inherited from class org.pgcodekeeper.core.database.ms.schema.MsConstraint
appendAlterSQL, getCreationSQL, getDropSQL, getTableName, setDisabled, setNotValidMethods inherited from class org.pgcodekeeper.core.database.ms.schema.MsAbstractStatement
appendOwnerSQL, formatSql, getQuoter, getRenameCommand, getSeparator, isOwnedMethods inherited from class org.pgcodekeeper.core.database.base.schema.AbstractStatement
addDependency, addPrivilege, 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, getSQL, getTwin, hasChildren, hashCode, isLib, setAuthor, setComment, setLibName, setLocation, setOwner, setParent, shallowCopy, toStringMethods inherited from interface org.pgcodekeeper.core.database.api.schema.IConstraint
getStatementType, getTableNameMethods inherited from interface org.pgcodekeeper.core.database.api.schema.ISearchPath
getDatabase, getSchemaNameMethods inherited from interface org.pgcodekeeper.core.database.api.schema.IStatement
addDependency, appendAlterSQL, appendOwnerSQL, canDrop, canDropBeforeCreate, clearPrivileges, deepCopy, formatSql, getAuthor, getBareName, getChildren, getComment, getCreationSQL, getDependencies, getDescendants, getDropSQL, 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
-
MsConstraintPk
Creates a new Microsoft SQL PRIMARY KEY or UNIQUE constraint.- Parameters:
name- the constraint nameisPrimaryKey- true for PRIMARY KEY, false for UNIQUE
-
-
Method Details
-
getDefinition
Description copied from interface:IConstraintGets the SQL definition of this constraint.- Specified by:
getDefinitionin interfaceIConstraint- Returns:
- the constraint definition
-
compareOptions
Description copied from interface:IOptionContainerCompares options between this container and a new container, generating SQL to update differences.- Specified by:
compareOptionsin interfaceIOptionContainer- Parameters:
newContainer- the new container to compare againstscript- the script to append changes to
-
isPrimaryKey
public boolean isPrimaryKey()Description copied from interface:IConstraintChecks if this constraint is a primary key constraint.- Specified by:
isPrimaryKeyin interfaceIConstraint- Returns:
- true if this is a primary key constraint
-
isClustered
public boolean isClustered()Description copied from interface:IConstraintPkChecks if this primary key constraint is clustered.- Specified by:
isClusteredin interfaceIConstraintPk- Returns:
- true if the primary key is clustered
-
setClustered
public void setClustered(boolean isClustered) -
setDataSpace
-
getColumns
Description copied from interface:IConstraintGets the columns involved in this constraint.- Specified by:
getColumnsin interfaceIConstraint- Overrides:
getColumnsin classMsConstraint- Returns:
- a collection of column names
-
containsColumn
Description copied from interface:IConstraintChecks if this constraint involves the specified column.- Specified by:
containsColumnin interfaceIConstraint- Overrides:
containsColumnin classMsConstraint- Parameters:
name- the column name to check- Returns:
- true if the column is part of this constraint
-
addColumn
Description copied from interface:ISimpleColumnContainerAdds a column reference to this container.- Specified by:
addColumnin interfaceISimpleColumnContainer- Parameters:
column- the simple column to add
-
addInclude
Throws an exception as include columns are not supported for primary key/unique constraints.- Specified by:
addIncludein interfaceISimpleColumnContainer- Parameters:
column- the column name (not used)- Throws:
IllegalStateException- always, as this operation is unsupported
-
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:
key- the option keyvalue- the option value
-
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- Overrides:
computeHashin classMsConstraint- 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 classMsConstraint
-