/** * Add an ALTER column clause (to change the column type) to this ALTER TABLE statement. * * @param columnName the name of the column to be altered. * @return a new {@link Alter.AlterColumn} instance. */ public AlterColumn alterColumn(String columnName) { validateNotEmpty(columnName, "Column to be altered"); validateNotKeyWord( columnName, String.format( "The altered column name '%s' is not allowed because it is a reserved keyword", columnName)); return new AlterColumn(this, columnName); }
@Test(groups = "unit") public void should_alter_column_type_with_keyspace() throws Exception { // When SchemaStatement statement = alterTable("ks", "test").alterColumn("name").type(DataType.ascii()); // Then assertThat(statement.getQueryString()) .isEqualTo("\n\tALTER TABLE ks.test ALTER name TYPE ascii"); }
@Test(groups = "unit") public void should_alter_column_type_to_UDT() throws Exception { // When SchemaStatement statement = alterTable("ks", "test").alterColumn("address").udtType(frozen("address")); // Then assertThat(statement.getQueryString()) .isEqualTo("\n\tALTER TABLE ks.test ALTER address TYPE frozen<address>"); }
/** * Add an ALTER column clause (to change the column type) to this ALTER TABLE statement. * * @param columnName the name of the column to be altered. * @return a new {@link Alter.AlterColumn} instance. */ public AlterColumn alterColumn(String columnName) { validateNotEmpty(columnName, "Column to be altered"); validateNotKeyWord(columnName, String.format("The altered column name '%s' is not allowed because it is a reserved keyword", columnName)); return new AlterColumn(this, columnName); }
/** * Add an ALTER column clause (to change the column type) to this ALTER TABLE statement. * * @param columnName the name of the column to be altered. * @return a new {@link Alter.AlterColumn} instance. */ public AlterColumn alterColumn(String columnName) { validateNotEmpty(columnName, "Column to be altered"); validateNotKeyWord(columnName, String.format("The altered column name '%s' is not allowed because it is a reserved keyword", columnName)); return new AlterColumn(this, columnName); }
/** * Add an ALTER column clause (to change the column type) to this ALTER TABLE statement. * * @param columnName the name of the column to be altered. * @return a new {@link Alter.AlterColumn} instance. */ public AlterColumn alterColumn(String columnName) { validateNotEmpty(columnName, "Column to be altered"); validateNotKeyWord(columnName, String.format("The altered column name '%s' is not allowed because it is a reserved keyword", columnName)); return new AlterColumn(this, columnName); }
@Test( groups = "unit", expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "The altered column name 'add' is not allowed because it is a reserved keyword") public void should_fail_if_altered_column_is_a_reserved_keyword() throws Exception { alterTable("test").alterColumn("add").type(DataType.ascii()).getQueryString(); }
@Test(groups = "unit") public void should_alter_column_type() throws Exception { // When SchemaStatement statement = alterTable("test").alterColumn("name").type(DataType.ascii()); // Then assertThat(statement.getQueryString()).isEqualTo("\n\tALTER TABLE test ALTER name TYPE ascii"); }
@Test(groups = "unit") public void should_alter_column_type_with_keyspace() throws Exception { // When SchemaStatement statement = alterTable("ks", "test").alterColumn("name").type(DataType.ascii()); // Then assertThat(statement.getQueryString()) .isEqualTo("\n\tALTER TABLE ks.test ALTER name TYPE ascii"); }
@Test(groups = "unit") public void should_alter_column_type_to_UDT() throws Exception { // When SchemaStatement statement = alterTable("ks", "test").alterColumn("address").udtType(frozen("address")); // Then assertThat(statement.getQueryString()) .isEqualTo("\n\tALTER TABLE ks.test ALTER address TYPE frozen<address>"); }
@Test( groups = "unit", expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "The altered column name 'add' is not allowed because it is a reserved keyword") public void should_fail_if_altered_column_is_a_reserved_keyword() throws Exception { alterTable("test").alterColumn("add").type(DataType.ascii()).getQueryString(); }
@Test(groups = "unit") public void should_alter_column_type() throws Exception { // When SchemaStatement statement = alterTable("test").alterColumn("name").type(DataType.ascii()); // Then assertThat(statement.getQueryString()).isEqualTo("\n\tALTER TABLE test ALTER name TYPE ascii"); }