Skip to content

Commit

Permalink
Merge branch 'master' into fix-5666
Browse files Browse the repository at this point in the history
  • Loading branch information
rberezen committed May 9, 2024
2 parents 3615b96 + 77f1384 commit eb48d4e
Show file tree
Hide file tree
Showing 30 changed files with 550 additions and 58 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/fossa_ai.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
name: FOSSA License Compliance and Security Check

on:
pull_request:
pull_request_target:
types:
- opened
- reopened
- synchronize

jobs:
authorize:
environment: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository && 'external' || 'internal' }}
runs-on: ubuntu-latest
steps:
- run: true

fossa:
needs: authorize
uses: liquibase/build-logic/.github/workflows/fossa_ai.yml@main
secrets: inherit
with:
Expand Down
1 change: 1 addition & 0 deletions liquibase-dist/expected-distribution-contents.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
├── internal
│   └── lib
│   ├── commons-collections4.jar
│   ├── commons-io.jar
│   ├── commons-lang3.jar
│   ├── commons-text.jar
│   ├── h2.jar
Expand Down
1 change: 1 addition & 0 deletions liquibase-dist/src/main/archive/licenses/oss/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Apache 2.0 License
- org.apache.commons:commons-lang3
- org.apache.commons:commons-text
- org.apache.commons:commons-collections4
- commons-io:commons-io

BSD 2 Clause License
- org.hsqldb:hsqldb
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package liquibase.command.core

import liquibase.Scope
import liquibase.command.util.CommandUtil
import liquibase.extension.testing.testsystem.DatabaseTestSystem
import liquibase.extension.testing.testsystem.TestSystemFactory
import liquibase.extension.testing.testsystem.spock.LiquibaseIntegrationTest
import liquibase.util.FileUtil
import static org.junit.Assert.fail
import spock.lang.Shared
import spock.lang.Specification

@LiquibaseIntegrationTest
class MssqlIntegrationTest extends Specification {
@Shared
private DatabaseTestSystem mssql = (DatabaseTestSystem) Scope.getCurrentScope().getSingleton(TestSystemFactory.class).getTestSystem("mssql")

def "Should not fail with merge statement"() {
given:
CommandUtil.runDropAll(mssql)
when:
CommandUtil.runUpdate(mssql,'src/test/resources/changelogs/mssql/issues/merge.statement.changelog.sql')
then:
noExceptionThrown()
cleanup:
CommandUtil.runDropAll(mssql)
}

def "verify store procedure does not get default endDelimiter added when a given delimiter is specified"() {
given:
CommandUtil.runUpdate(mssql,'src/test/resources/changelogs/mssql/issues/create.procedure.changelog.sql')

def sProcedureName = "TestProcedure"
def getStoreProcedureContentQuery = String.format("""
SELECT ISNULL(smsp.definition, ssmsp.definition) AS [SPBody]
FROM sys.all_objects AS sp LEFT OUTER JOIN sys.sql_modules AS smsp ON smsp.object_id = sp.object_id
LEFT OUTER JOIN sys.system_sql_modules AS ssmsp ON ssmsp.object_id = sp.object_id
WHERE (sp.type = N'P' OR sp.type = N'RF' OR sp.type='PC')and(sp.name=N'%s' and SCHEMA_NAME(sp.schema_id)=N'dbo')
""", sProcedureName)

when:
def resultSet = mssql.getConnection().prepareStatement(getStoreProcedureContentQuery).executeQuery()

then:
def changelogContent = FileUtil.getContents(new File('src/test/resources/changelogs/mssql/issues/create.procedure.changelog.sql'))
if(resultSet.next()) {
def deployedSPContent = resultSet.getString("SPBody")
changelogContent.contains(deployedSPContent.split(String.format("procedure dbo.%s", sProcedureName))[1])
} else {
fail(String.format("There is not procedure stored in the DB with name %s", sProcedureName))
}
}

def "Should not fail with execution of create procedures with begin-end blocks"() {
when:
CommandUtil.runUpdate(mssql,'src/test/resources/changelogs/mssql/issues/begin.examples.changelog.xml')
then:
noExceptionThrown()
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,8 @@

<includeAll path="changelogs/common/pathincluded/" minDepth="0" maxDepth="1"/>

<include relativeToChangelogFile="true" file="depthboundincludeall/changelog.xml" />

<include file="includerelative\pathinclude1.changelog.xml" relativeToChangelogFile="true"/> <!-- try with dos style path -->

<changeSet id="autocommitTest" author="nvoxland" runInTransaction="false">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<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-latest.xsd"
>
<changeSet
id="invalid_a"
author="jlyle"
>
<output>Changeset A</output>
<sql>select foo from dual</sql>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<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-latest.xsd"
>
<changeSet
id="invalid_b"
author="jlyle"
>
<output>Changeset B</output>
<sql>select foo from dual</sql>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<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-latest.xsd"
>
<changeSet
id="invalid_c"
author="jlyle"
>
<output>Changeset C</output>
<sql>select foo from dual</sql>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<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-latest.xsd"
>
<changeSet
id="invalid_d"
author="jlyle"
>
<output>Changeset D</output>
<sql>select foo from dual</sql>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<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-latest.xsd"
>
<changeSet
id="valid_e"
author="jlyle"
>
<output>Changeset E</output>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<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-latest.xsd"
>
<changeSet
id="valid_f"
author="jlyle"
>
<output>Changeset F</output>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<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-latest.xsd"
>
<changeSet
id="invalid_g"
author="jlyle"
>
<output>Changeset G</output>
<sql>select foo from dual</sql>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<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-latest.xsd"
>
<changeSet
id="root_include"
author="jlyle"
>
<output>Root</output>
</changeSet>

<!-- <include relativeToChangelogFile="true" file="a/b/c/d/e/e.xml" />
<include relativeToChangelogFile="true" file="a/b/c/d/e/f/f.xml" /> -->
<includeAll relativeToChangelogFile="true" path="a/b/c" minDepth="3" maxDepth="4" />
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>

<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-latest.xsd">
<changeSet id="1" author="mallod">
<sqlFile endDelimiter="\nGO" encoding="cp1250" path="src/test/resources/changelogs/mssql/issues/create.procedure.examples.with.begin.end.block.sql" splitStatements="true"/>
</changeSet>

<changeSet id="2" author="mallod">
<sql>
CREATE TABLE TestCommitTable(id int, name varchar(255));

BEGIN TRANSACTION;
DELETE FROM TestCommitTable
COMMIT;
</sql>
</changeSet>

</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- liquibase formatted sql
--changeset mallod:endDelimiterTest runOnChange:true stripComments:false splitStatements:true endDelimiter:;;;;;
create or alter procedure dbo.TestProcedure
as
select top 5 *
from
dbo.CustomerMaster
where
TerritoryID = 2
and IsActive = 1
;;;;;
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
CREATE PROCEDURE dbo.A
AS
BEGIN
SET NOCOUNT ON;

DECLARE @handle UNIQUEIDENTIFIER;

BEGIN DIALOG @handle
FROM SERVICE [//aa/BB/Service]
TO SERVICE '//aa/BB/Service'
ON CONTRACT [//aa/BB/Contract]
WITH ENCRYPTION = OFF;

SEND ON CONVERSATION @handle MESSAGE TYPE [//aa/BB/Type];

END;
GO
CREATE PROCEDURE dbo.B
AS
BEGIN
SET NOCOUNT ON;

DECLARE @queue TABLE (message_type_name VARCHAR(256));

WAITFOR (
RECEIVE message_type_name FROM dbo.que_bindata
INTO @queue
);

DELETE
FROM dbo.data_tmp
WHERE start_date< DATEADD(DAY, - 1, GETDATE());
END;
GO
CREATE PROCEDURE dbo.C
AS
BEGIN
SET NOCOUNT ON;

BEGIN DISTRIBUTED TRANSACTION;
-- Delete candidate from local instance.
DELETE dbo.HumanResources.JobCandidate
COMMIT TRANSACTION;
END;
GO
5 changes: 5 additions & 0 deletions liquibase-standard/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@
<version>1.18.32</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import liquibase.servicelocator.LiquibaseService;
import liquibase.util.FileUtil;
import liquibase.util.StringUtil;
import org.apache.commons.io.FilenameUtils;

import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -535,7 +536,7 @@ public void handleChildNodeHelper(ParsedNode node, ResourceAccessor resourceAcce
includeContextFilter,
labels,
ignore,
node.getChildValue(null, MIN_DEPTH, 1),
node.getChildValue(null, MIN_DEPTH, 0),
node.getChildValue(null, MAX_DEPTH, Integer.MAX_VALUE),
node.getChildValue(null, ENDS_WITH_FILTER, ""),
(ModifyChangeSets) nodeScratch.get(MODIFY_CHANGE_SETS));
Expand Down Expand Up @@ -1086,7 +1087,15 @@ public static String normalizePath(String filePath) {
filePath = filePath.substring(1);
}

filePath = Paths.get(filePath).normalize().toString();
String normalized = FilenameUtils.normalizeNoEndSeparator(filePath);
/*
Commons IO will return null if the double dot has no parent path segment to work with. In this case,
we fall back to path normalization using Paths.get(), which might fail on Windows.
*/
if (normalized == null) {
normalized = Paths.get(filePath).normalize().toString();
}
filePath = normalized;

if (filePath.contains("\\")) {
filePath = filePath.replace("\\", "/");
Expand Down

0 comments on commit eb48d4e

Please sign in to comment.