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

Fix/load relative file (fixes child of #1277) #2060

Closed
wants to merge 4 commits into from

Conversation

smainz
Copy link

@smainz smainz commented Aug 31, 2021

Environment

Liquibase Version: 4.4.3 (and all 4.x before)

Liquibase Integration & Version: any

Liquibase Extension(s) & Version: liquibase-core

Database Vendor & Version: H2 (and all others)

Operating System Type & Version: Windows 10 (and all others)

Pull Request Type

  • Bug fix (non-breaking change which fixes an issue.) relative bug fix for sql files #1798 fixed the problem of loading files relative for SQLFileChange, but not for LoadDataChange, CreateProcedureChange or CreateViewChange. This PR solves this.
  • Enhancement/New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

See #1277, but for LoadDataChange, CreateProcedureChange or CreateViewChange.
Testcases showing the problem are included in this PR.

Steps To Reproduce

List the steps to reproduce the behavior.

  • create a changelog file with these change sets
    <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
      			     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      			     xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
                          http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.10.xsd"
      			     logicalFilePath="a-logical-file-path"
    >
        <changeSet id="1" author="author">
      	  <loadData file="data/some_data.csv" tableName="a_tabe"
      			   relativeToChangelogFile="true"></loadData>
        </changeSet>
    
        <changeSet id="2" author="author">
      	  <createProcedure path="sql/proc.sql"
      					   relativeToChangelogFile="true"></createProcedure>
        </changeSet>
    
        <changeSet id="3" author="author">
      	  <createView path="sql/view.sql" viewName="a_view"
      				  relativeToChangelogFile="true"></createView>
        </changeSet>
    
    </databaseChangeLog>
    
  • Create these files (may be empty)
    • data/some_data.csv
    • sql/proc.sql
    • sql/view.sql
  • Run liquibase update against the db
liquibase --driver=com.microsoft.sqlserver.jdbc.SQLServerDriver --url="jdbc:sqlserver://localhost:1433;database=the_database" --changeLogFile=changelog.xml  --username=the_username --password=thepassword --logLevel=debug update
  • See it fail
  • Comment the changeset and repeat (fails for all three)

Actual Behavior

Liquibase throws an exception complaining about missing file (a different one for each changeset):

liquibase.exception.LiquibaseException: liquibase.exception.UnexpectedLiquibaseException: File 'data/some_data.csv' not found

Expected/Desired Behavior

Liquibase does not complain about missing files and works flawlessly.

Additional Context

Same bug has already been fixed in #1798 for a diffenent change. The changes above have been overlooked.

I had to fix an existing testcase which used a changeset not included in an changelog.

Fast Track PR Acceptance Checklist:

  • Build is successful and all new and existing tests pass (all in liquibase.core)
  • Added [Unit Test(s)] Enhanced existing unit tests
  • Added [Integration Test(s)]
  • Added Test Harness Test(s)
  • Documentation Updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant