Examples of UniqueConstraint


Examples of liquibase.structure.core.UniqueConstraint

            if (!StringUtils.join(referenceColumns, ",", formatter).equalsIgnoreCase(StringUtils.join(comparedColumns, ",", formatter))) {
                control.setAlreadyHandledChanged(new Index().setTable(index.getTable()).setColumns(comparedColumns));
            }
   
            if (index.isUnique() != null && index.isUnique()) {
                control.setAlreadyHandledChanged(new UniqueConstraint().setTable(index.getTable()).setColumns(referenceColumns));
                if (!StringUtils.join(referenceColumns, ",", formatter).equalsIgnoreCase(StringUtils.join(comparedColumns, ",", formatter))) {
                    control.setAlreadyHandledChanged(new UniqueConstraint().setTable(index.getTable()).setColumns(comparedColumns));
                }
            }
        }

        return new Change[] { dropIndexChange, addIndexChange };
View Full Code Here

Examples of liquibase.structure.core.UniqueConstraint

    }

    @Override
    public void checkDiffResult(DiffResult diffResult, AddUniqueConstraintChange change) {
        diffResult.getUnexpectedObject(new UniqueConstraint(change.getConstraintName(), change.getCatalogName(), change.getSchemaName(), change.getTableName()));
    }
View Full Code Here

Examples of liquibase.structure.core.UniqueConstraint

            for (int i=0; i<columnNames.length; i++) {
                columns[i] = new Column(columnNames[i]);
            }
        }

        assertNotNull(diffResult.getMissingObject(new UniqueConstraint(change.getConstraintName(), change.getCatalogName(), change.getSchemaName(), change.getTableName(), columns)));
    }
View Full Code Here

Examples of net.sf.hajdbc.UniqueConstraint

  {
    ResultSet resultSet = metaData.getPrimaryKeys(getCatalog(metaData), table.getSchema(), table.getName());
   
    try
    {
      UniqueConstraint constraint = null;

      while (resultSet.next())
      {
        if (constraint == null)
        {
          constraint = factory.createUniqueConstraint(resultSet.getString("PK_NAME"), table);
        }
       
        constraint.getColumnList().add(resultSet.getString("COLUMN_NAME"));
      }
     
      return constraint;
    }
    finally
View Full Code Here

Examples of net.sf.hajdbc.UniqueConstraint

      {
        if (resultSet.getShort("TYPE") == DatabaseMetaData.tableIndexHashed)
        {
          String name = resultSet.getString("INDEX_NAME");
         
          UniqueConstraint key = keyMap.get(name);
         
          if (key == null)
          {
            key = factory.createUniqueConstraint(name, table);
           
            // Don't include the primary key
            if (key.equals(primaryKey)) continue;
           
            keyMap.put(name, key);
          }
         
          key.getColumnList().add(resultSet.getString("COLUMN_NAME"));
        }
      }
      return keyMap.values();
    }
    finally
View Full Code Here

Examples of net.sf.hajdbc.UniqueConstraint

  @Override
  public <Z, D extends Database<Z>> void synchronize(SynchronizationContext<Z, D> context, TableProperties table) throws SQLException
  {
    String tableName = table.getName().getDMLName();
   
    UniqueConstraint primaryKey = table.getPrimaryKey();
   
    if (primaryKey == null)
    {
      throw new SQLException(Messages.PRIMARY_KEY_REQUIRED.getMessage(this.getClass().getName(), tableName));
    }
   
    List<String> primaryKeyColumns = primaryKey.getColumnList();
   
    Collection<String> columns = table.getColumns();
   
    List<String> nonPrimaryKeyColumns = new ArrayList<String>(columns.size());
    List<String> versionColumns = new ArrayList<String>(columns.size());
View Full Code Here

Examples of net.sf.hajdbc.UniqueConstraint

   */
  @Override
  public void getCreateUniqueConstraintSQL() throws SQLException
  {
    QualifiedName table = mock(QualifiedName.class);
    UniqueConstraint constraint = mock(UniqueConstraint.class);
   
    when(table.getDDLName()).thenReturn("table");
    when(constraint.getName()).thenReturn("name");
    when(constraint.getTable()).thenReturn(table);
    when(constraint.getColumnList()).thenReturn(Arrays.asList("column1", "column2"));
   
    String result = this.dialect.getCreateUniqueConstraintSQL(constraint);
   
    assertEquals("ALTER TABLE table ADD UNIQUE name (column1, column2)", result);
  }
View Full Code Here

Examples of net.sf.hajdbc.UniqueConstraint

   */
  @Override
  public void getDropUniqueConstraintSQL() throws SQLException
  {
    QualifiedName table = mock(QualifiedName.class);
    UniqueConstraint constraint = mock(UniqueConstraint.class);
   
    when(table.getDDLName()).thenReturn("table");
    when(constraint.getName()).thenReturn("name");
    when(constraint.getTable()).thenReturn(table);
    when(constraint.getColumnList()).thenReturn(Arrays.asList("column1", "column2"));
   
    String result = this.dialect.getDropUniqueConstraintSQL(constraint);
   
    assertEquals("ALTER TABLE table DROP INDEX name", result);
  }
View Full Code Here

Examples of net.sf.hajdbc.UniqueConstraint

  @Test
  public void getCreateUniqueConstraintSQL() throws SQLException
  {
    QualifiedName table = mock(QualifiedName.class);
    UniqueConstraint constraint = mock(UniqueConstraint.class);
   
    when(table.getDDLName()).thenReturn("table");
    when(constraint.getName()).thenReturn("name");
    when(constraint.getTable()).thenReturn(table);
    when(constraint.getColumnList()).thenReturn(Arrays.asList("column1", "column2"));
   
    String result = this.dialect.getCreateUniqueConstraintSQL(constraint);
   
    assertEquals("ALTER TABLE table ADD CONSTRAINT name UNIQUE (column1, column2)", result);
  }
View Full Code Here

Examples of net.sf.hajdbc.UniqueConstraint

  @Test
  public void getDropUniqueConstraintSQL() throws SQLException
  {
    QualifiedName table = mock(QualifiedName.class);
    UniqueConstraint constraint = mock(UniqueConstraint.class);
   
    when(table.getDDLName()).thenReturn("table");
    when(constraint.getName()).thenReturn("name");
    when(constraint.getTable()).thenReturn(table);
    when(constraint.getColumnList()).thenReturn(Arrays.asList("column1", "column2"));
   
    String result = this.dialect.getDropUniqueConstraintSQL(constraint);
   
    assertEquals("ALTER TABLE table DROP CONSTRAINT name", result);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.