Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support adding computed=true columns with no type set #2340

Merged
merged 5 commits into from Feb 14, 2022

Conversation

nvoxland
Copy link
Contributor

@nvoxland nvoxland commented Jan 6, 2022

Description

Fixes #2283 by only requiring type when computed is false or not set.


Dev Handoff Notes (Internal Use)

Links

Testing

Dev Verification

Tested the following changesets:

    <changeSet id="1" author="me">
        <createTable tableName="event">
            <column name="id" type="int"/>
            <column name="payload" type="varchar(10)"/>
        </createTable>
    </changeSet>
    <changeSet id="2" author="me">
        <addColumn tableName="event">
            <column name="payload_id AS JSON_VALUE(payload,'$.id')"
                    computed="true">
            </column>
        </addColumn>
    </changeSet>

    <changeSet id="4" author="nvoxland">
        <addColumn tableName="event">
            <column name="other_id" type="int"/>
        </addColumn>
    </changeSet>

including taking "type" off addColumn on id=4 to make sure that was still flagged as required when computed was not set

Manual testing
Setup
Use next changelog:

<changeSet id="1" author="Liquibase" labels="setup">
        	<createTable tableName="test_table1">
            		<column name="id" type="int"/>
            		<column name="value" type="varchar(10)"/>
        	</createTable>
    	</changeSet>

   	<changeSet id="2" author="Liquibase" labels="fix">
        	<addColumn tableName="test_table1">
            		<column name="value_id AS JSON_VALUE(value,'$.id')"
                    		computed="true">
            		</column>
        	</addColumn>
    	</changeSet>

	<changeSet id="3" author="Liquibase" labels="addError">
        	<addColumn tableName="test_table1">
            		<column name="third_id"/>
        	</addColumn>
    	</changeSet>
	
	<changeSet id="4" author="Liquibase" labels="test">
        	<createTable tableName="test_table2">
            		<column name="id" type="int"/>
            		<column name="value" type="varchar(10)"/>
			<column name="value_id AS JSON_VALUE(value,'$.id')"
                    		computed="true"/>
        	</createTable>
    	</changeSet>

	<changeSet id="5" author="Liquibase" labels="createError">
        	<createTable tableName="test_table3">
            		<column name="id" type="int"/>
            		<column name="value"/>
        	</createTable>
    	</changeSet>

Execute liquibase update --changelog-file changelog.xml --labels setup

Text cases
Verify update is successful for computed=true columns when there is no type attribute.

  • liquibase update --changelog-file changelog.xml --labels fix,test
  • update is successful
  • computed column value_id is created for test_table1
  • test_table2 is created with computed column value_id

Verify update throws an error when type attribute is missing for not computed column.

  • liquibase update --changelog-file changelog.xml --labels addError
  • columnType is required error is shown
  • liquibase update --changelog-file changelog.xml --labels createError
  • column 'type' is required for all columns error message is shown

┆Issue is synchronized with this Jira Bug by Unito

@nvoxland nvoxland added this to To Do in Conditioning++ via automation Jan 6, 2022
@nvoxland nvoxland moved this from To Do to Code Review in Conditioning++ Jan 6, 2022
@suryaaki2 suryaaki2 moved this from Code Review to Ready for Handoff (In JIRA) in Conditioning++ Jan 21, 2022
@yodzhubeiskyi
Copy link
Contributor

Text results
Verify update is successful for computed=true columns when there is no type attribute. PASS

Running Changeset: changelog.xml::2::Liquibase
Running Changeset: changelog.xml::4::Liquibase
Liquibase command 'update' was executed successfully.

Verify update throws an error when type attribute is missing for not computed column. PASS

Unexpected error running Liquibase: Validation Failed:
     1 changes have validation failures
          columnType is required, changelog.xml::3::Liquibase
Unexpected error running Liquibase: Validation Failed:
     1 changes have validation failures
          column 'type' is required for all columns, changelog.xml::5::Liquibase

Liquibase version [Core: //support-add-computed-column/1463/67a603/2022-02-10 16:32+0000, Pro: master/591/f653ec/2022-02-09T18:09:13Z] #1463

@nvoxland nvoxland merged commit d4f80c3 into master Feb 14, 2022
Conditioning++ automation moved this from Ready for Handoff (In JIRA) to Done Feb 14, 2022
@nvoxland nvoxland deleted the support-add-computed-column branch February 14, 2022 14:51
@nvoxland nvoxland added this to the v4.8.0 milestone Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

It is no longer possible to create calculated columns on mssql
4 participants