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

Bump org.liquibase:liquibase-core from 4.23.2 to 4.24.0 #467

Merged
merged 3 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ plugins:
extra:
maven_central: https://repo1.maven.org/maven2
github_repo: https://github.com/liquibase/liquibase-neo4j
liquibase_version: 4.23.2
liquibase_version: 4.24.0
group_id: org.liquibase.ext
group_id_url: org/liquibase/ext
artifact_id: liquibase-neo4j
version: 4.23.2
version: 4.24.0
extra_css:
- css/extra.css
markdown_extensions:
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-neo4j</artifactId>
<version>4.23.3-SNAPSHOT</version>
<version>4.24.0-SNAPSHOT</version>

<name>Liquibase Neo4j Database Extension</name>
<description>Adds additional Neo4j specific Liquibase functionality</description>
Expand Down Expand Up @@ -64,7 +64,7 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.enforcer.requireJavaVersion>${maven.compiler.source}</maven.enforcer.requireJavaVersion>
<liquibase.version>4.23.2</liquibase.version>
<liquibase.version>4.24.0</liquibase.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven-release-plugin.version>3.0.1</maven-release-plugin.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public SqlStatement[] generateStatements(Database database) {
}
return new SqlStatement[]{
new RawParameterizedSqlStatement(
String.format("CREATE (node:`%s`) SET node = $0", this.getTableName()),
String.format("CREATE (node:`%s`) SET node = $1", this.getTableName()),
propertyMap(this.getColumns())
)
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public boolean supports(Database database) {

@Override
protected SqlStatement[] generateStatementsFromRows(Database database, List<LoadDataRowConfig> rows) {
String cypher = String.format("UNWIND $0 AS row CREATE (n:`%s`) SET n += row", escapeLabel(getTableName()));
String cypher = String.format("UNWIND $1 AS row CREATE (n:`%s`) SET n += row", escapeLabel(getTableName()));
return new SqlStatement[]{new RawParameterizedSqlStatement(cypher, keyValuePairs(rows))};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private List<Long> getNodeIds(MatchPattern pattern) throws LiquibaseException {

private Optional<SqlStatement> generateLabelCopyStatement(List<Long> ids) throws LiquibaseException {
List<Map<String, ?>> rows = database.run(new RawParameterizedSqlStatement(
"MATCH (n) WHERE ID(n) IN $0\n" +
"MATCH (n) WHERE ID(n) IN $1\n" +
"UNWIND labels(n) AS label\n" +
"WITH DISTINCT label\n" +
"ORDER BY label ASC\n" +
Expand All @@ -62,13 +62,13 @@ private Optional<SqlStatement> generateLabelCopyStatement(List<Long> ids) throws
labelLiterals.add(label);
}
return Optional.of(new RawParameterizedSqlStatement(
String.format("MATCH (n) WHERE ID(n) = $0 SET n%s", labelLiterals),
String.format("MATCH (n) WHERE ID(n) = $1 SET n%s", labelLiterals),
ids.get(0)));
}

private Optional<SqlStatement> generatePropertyCopyStatement(List<Long> ids, List<PropertyMergePolicy> policies) throws LiquibaseException {
List<Map<String, ?>> rows = database.run(new RawParameterizedSqlStatement(
"UNWIND $0 AS id\n" +
"UNWIND $1 AS id\n" +
"MATCH (n) WHERE id(n) = id\n" +
"UNWIND keys(n) AS key\n" +
"WITH key, n[key] as value\n" +
Expand Down Expand Up @@ -96,14 +96,14 @@ private Optional<SqlStatement> generatePropertyCopyStatement(List<Long> ids, Lis
}

return Optional.of(new RawParameterizedSqlStatement(
"MATCH (n) WHERE id(n) = $0 SET n = $1",
"MATCH (n) WHERE id(n) = $1 SET n = $2",
asList(ids.get(0), combinedProperties).toArray()));
}

private Optional<SqlStatement> generateRelationshipCopyStatements(List<Long> ids) throws LiquibaseException {
Set<Long> nodeIdTail = tailOf(ids);
List<Map<String, ?>> rows = database.run(new RawParameterizedSqlStatement(
"MATCH (n) WHERE id(n) IN $0\n" +
"MATCH (n) WHERE id(n) IN $1\n" +
"WITH [ (n)-[r]-() | r ] AS rels\n" +
"UNWIND rels AS rel\n" +
"RETURN DISTINCT rel\n" +
Expand All @@ -113,16 +113,16 @@ private Optional<SqlStatement> generateRelationshipCopyStatements(List<Long> ids
if (rows.isEmpty()) {
return Optional.empty();
}
int parameterIndex = 0;
int parameterIndex = 1;
StringBuilder query = new StringBuilder();
List<Object> parameters = new ArrayList<>();
query.append("MATCH (target) WHERE id(target) = $0 ");
parameters.add(ids.get(0));
query.append(String.format("MATCH (target) WHERE id(target) = $%d ", parameterIndex));
parameters.add(parameterIndex-1, ids.get(0));
parameterIndex++;
for (Map<String, ?> row : rows) {
@SuppressWarnings("unchecked")
Map<String, Object> relation = (Map<String, Object>) row.get("rel");
parameters.add(parameterIndex, relProperties(relation));
parameters.add(parameterIndex-1, relProperties(relation));
long startId = (long) relation.get("_startId");
long endId = (long) relation.get("_endId");
if (nodeIdTail.contains(startId) && nodeIdTail.contains(endId)) { // current or post-merge self-rel
Expand All @@ -131,11 +131,11 @@ private Optional<SqlStatement> generateRelationshipCopyStatements(List<Long> ids
continue;
}
if (nodeIdTail.contains(endId)) { // incoming
parameters.add(parameterIndex + 1, startId);
parameters.add(parameterIndex, startId);
query.append(String.format("WITH target MATCH (n_%1$d) WHERE id(n_%1$d) = $%1$d ", parameterIndex + 1));
query.append(String.format("CREATE (n_%1$d)-[rel_%1$d:`%2$s`]->(target) SET rel_%1$d = $%3$d ", parameterIndex + 1, relation.get("_type"), parameterIndex));
} else { // outgoing
parameters.add(parameterIndex + 1, endId);
parameters.add(parameterIndex, endId);
query.append(String.format("WITH target MATCH (n_%1$d) WHERE id(n_%1$d) = $%1$d ", parameterIndex + 1));
query.append(String.format("CREATE (n_%1$d)<-[rel_%1$d:`%2$s`]-(target) SET rel_%1$d = $%3$d ", parameterIndex + 1, relation.get("_type"), parameterIndex));
}
Expand All @@ -146,7 +146,7 @@ private Optional<SqlStatement> generateRelationshipCopyStatements(List<Long> ids

private Optional<SqlStatement> generateNodeDeletion(List<Long> ids) {
return Optional.of(new RawParameterizedSqlStatement(
"MATCH (n) WHERE id(n) IN $0 DETACH DELETE n",
"MATCH (n) WHERE id(n) IN $1 DETACH DELETE n",
tailOf(ids)
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ public List<RanChangeSet> getRanChangeSets() throws DatabaseException {
public void replaceChecksum(ChangeSet changeSet) throws DatabaseException {
try {
database.execute(new RawParameterizedSqlStatement(
"MATCH (changeSet:__LiquibaseChangeSet {id: $0, author: $1, changeLog: $2})-[:IN_CHANGELOG]->(changeLog:__LiquibaseChangeLog) " +
"SET changeLog.dateUpdated = datetime() SET changeSet.checkSum = $3",
"MATCH (changeSet:__LiquibaseChangeSet {id: $1, author: $2, changeLog: $3})-[:IN_CHANGELOG]->(changeLog:__LiquibaseChangeLog) " +
"SET changeLog.dateUpdated = datetime() SET changeSet.checkSum = $4",
changeSet.getId(),
changeSet.getAuthor(),
changeSet.getFilePath(),
Expand Down Expand Up @@ -165,7 +165,7 @@ public void setExecType(ChangeSet changeSet, ChangeSet.ExecType execType) throws
public void removeFromHistory(ChangeSet changeSet) throws DatabaseException {
try {
database.execute(new RawParameterizedSqlStatement(
"MATCH (changeSet:__LiquibaseChangeSet {id: $0, author: $1, changeLog: $2 })-[:IN_CHANGELOG]->(changeLog:__LiquibaseChangeLog) " +
"MATCH (changeSet:__LiquibaseChangeSet {id: $1, author: $2, changeLog: $3 })-[:IN_CHANGELOG]->(changeLog:__LiquibaseChangeLog) " +
"SET changeLog.dateUpdated = datetime() DETACH DELETE changeSet",
changeSet.getId(),
changeSet.getAuthor(),
Expand Down Expand Up @@ -211,7 +211,7 @@ public void tag(String tagString) throws DatabaseException {
@Override
public boolean tagExists(String tag) throws DatabaseException {
Executor executor = Scope.getCurrentScope().getSingleton(ExecutorService.class).getExecutor("jdbc", database);
long count = executor.queryForLong(new RawParameterizedSqlStatement("MATCH (t:__LiquibaseTag {tag: $0}) RETURN count(t) AS count", tag));
long count = executor.queryForLong(new RawParameterizedSqlStatement("MATCH (t:__LiquibaseTag {tag: $1}) RETURN count(t) AS count", tag));
database.rollback();
return count > 0;
}
Expand Down Expand Up @@ -267,12 +267,12 @@ private void updateChangeSet(ChangeSet changeSet, ChangeSet.ExecType execType, i
"MATCH (changeLog:__LiquibaseChangeLog) " +
"SET changeLog.dateUpdated = datetime() " +
"WITH changeLog " +
"MATCH (changeSet:__LiquibaseChangeSet {id: $0, author: $1, changeLog: $2 })-[changeSetExecution:IN_CHANGELOG]->(changeLog) " +
"MATCH (changeSet:__LiquibaseChangeSet {id: $1, author: $2, changeLog: $3 })-[changeSetExecution:IN_CHANGELOG]->(changeLog) " +
"SET changeSetExecution.dateExecuted = datetime() " +
"SET changeSetExecution.orderExecuted = $3 " +
"SET changeSet.checkSum = $4 " +
"SET changeSet.execType = $5 " +
"SET changeSet.deploymentId = $6 ",
"SET changeSetExecution.orderExecuted = $4 " +
"SET changeSet.checkSum = $5 " +
"SET changeSet.execType = $6 " +
"SET changeSet.deploymentId = $7 ",
changeSet.getId(),
changeSet.getAuthor(),
changeSet.getFilePath(),
Expand All @@ -288,19 +288,19 @@ private void insertChangeSet(ChangeSet changeSet, ChangeSet.ExecType execType, i
"MATCH (changeLog:__LiquibaseChangeLog) " +
"SET changeLog.dateUpdated = datetime() " +
"CREATE (changeSet:__LiquibaseChangeSet {" +
" changeLog: $0, " +
" id: $1," +
" author: $2," +
" checkSum: $3," +
" execType: $4, " +
" description: $5, " +
" comments: $6, " +
" deploymentId: $7, " +
" storedChangeLog: $8, " +
" liquibaseVersion: $9 " +
" changeLog: $1, " +
" id: $2," +
" author: $3," +
" checkSum: $4," +
" execType: $5, " +
" description: $6, " +
" comments: $7, " +
" deploymentId: $8, " +
" storedChangeLog: $9, " +
" liquibaseVersion: $10 " +
"})-[:IN_CHANGELOG {" +
" dateExecuted: datetime(), " +
" orderExecuted: $10 " +
" orderExecuted: $11 " +
"}]->(changeLog)",
changeSet.getFilePath(),
changeSet.getId(),
Expand All @@ -318,7 +318,7 @@ private void insertChangeSet(ChangeSet changeSet, ChangeSet.ExecType execType, i

private void reLinkChangeSet(ChangeSet changeSet) throws LiquibaseException {
database.execute(new RawParameterizedSqlStatement(
"MATCH (changeSet:__LiquibaseChangeSet {id: $0, author: $1, changeLog: $2 })-[:IN_CHANGELOG]->(:__LiquibaseChangeLog) " +
"MATCH (changeSet:__LiquibaseChangeSet {id: $1, author: $2, changeLog: $3 })-[:IN_CHANGELOG]->(:__LiquibaseChangeLog) " +
"OPTIONAL MATCH (changeSet)<-[c:CONTEXTUALIZES]-(:__LiquibaseContext) DELETE c " +
"WITH changeSet " +
"OPTIONAL MATCH (changeSet)<-[l:LABELS]-(:__LiquibaseLabel) DELETE l ",
Expand All @@ -338,8 +338,8 @@ private void linkContexts(ChangeSet changeSet) throws LiquibaseException {
}
for (String context : contexts.getContexts()) {
database.execute(new RawParameterizedSqlStatement(
"MATCH (changeSet:__LiquibaseChangeSet {id: $0, author: $1, changeLog: $2 }) " +
"MERGE (context:__LiquibaseContext{ context: $3 }) " +
"MATCH (changeSet:__LiquibaseChangeSet {id: $1, author: $2, changeLog: $3 }) " +
"MERGE (context:__LiquibaseContext{ context: $4 }) " +
" ON CREATE SET context.dateCreated = datetime() " +
" ON MATCH SET context.dateUpdated = datetime() " +
"CREATE (context)-[:CONTEXTUALIZES]->(changeSet)",
Expand All @@ -358,8 +358,8 @@ private void linkLabels(ChangeSet changeSet) throws LiquibaseException {
}
for (String label : labels.getLabels()) {
database.execute(new RawParameterizedSqlStatement(
"MATCH (changeSet:__LiquibaseChangeSet {id: $0, author: $1, changeLog: $2 }) " +
"MERGE (label:__LiquibaseLabel{ label: $3 }) " +
"MATCH (changeSet:__LiquibaseChangeSet {id: $1, author: $2, changeLog: $3 }) " +
"MERGE (label:__LiquibaseLabel{ label: $4 }) " +
" ON CREATE SET label.dateCreated = datetime() " +
" ON MATCH SET label.dateUpdated = datetime() " +
"CREATE (label)-[:LABELS]->(changeSet)",
Expand Down Expand Up @@ -392,13 +392,13 @@ private void linkTag(ChangeSet changeSet) throws LiquibaseException {

String tag = tagValues.iterator().next();
database.execute(new RawParameterizedSqlStatement(
"MERGE (tag:__LiquibaseTag {tag: $0}) " +
"MERGE (tag:__LiquibaseTag {tag: $1}) " +
" ON CREATE SET tag.dateCreated = datetime()" +
" ON MATCH SET tag.dateUpdated = datetime() " +
"WITH tag " +
"OPTIONAL MATCH (tag)-[r:TAGS]->(:__LiquibaseChangeSet) DELETE r " +
"WITH tag " +
"MATCH (changeSet:__LiquibaseChangeSet {id: $1, author: $2, changeLog: $3 }) " +
"MATCH (changeSet:__LiquibaseChangeSet {id: $2, author: $3, changeLog: $4 }) " +
"OPTIONAL MATCH (changeSet)<-[r:TAGS]-(:__LiquibaseTag) DELETE r " +
"CREATE (tag)-[:TAGS]->(changeSet)",
tag,
Expand All @@ -422,7 +422,7 @@ private Map<String, Object> mergeTag(String tagString) throws DatabaseException
Executor executor = Scope.getCurrentScope().getSingleton(ExecutorService.class).getExecutor("jdbc", database);
@SuppressWarnings("unchecked")
List<Map<String, Object>> changeSetIds = executor.queryForList(new RawParameterizedSqlStatement(
"MERGE (tag:__LiquibaseTag {tag: $0}) " +
"MERGE (tag:__LiquibaseTag {tag: $1}) " +
" ON CREATE SET tag.dateCreated = datetime() " +
" ON MATCH SET tag.dateUpdated = datetime() " +
"WITH tag " +
Expand Down Expand Up @@ -556,7 +556,7 @@ private void readCheckSums() throws DatabaseException {
boolean result = executor.queryForObject(
new RawParameterizedSqlStatement(
"MATCH (changeSet:__LiquibaseChangeSet)-[:IN_CHANGELOG]->(: __LiquibaseChangeLog)" +
" WHERE NOT changeSet.checkSum STARTS WITH $0" +
" WHERE NOT changeSet.checkSum STARTS WITH $1" +
" RETURN count(changeSet) > 0",
String.format("%d:", currentCheckSumVersion.getVersion())
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public boolean acquireLock() throws LockException {
init();
UUID newLockId = UUID.randomUUID();
database.execute(new RawParameterizedSqlStatement(
"CREATE (lock:__LiquibaseLock {id: $0, grantDate: datetime(), lockedBy: $1})",
"CREATE (lock:__LiquibaseLock {id: $1, grantDate: datetime(), lockedBy: $2})",
newLockId.toString(),
Neo4jLockService.class.getSimpleName()
));
Expand Down Expand Up @@ -158,7 +158,7 @@ public void releaseLock() throws LockException {
}
try {
database.execute(new RawParameterizedSqlStatement(
"MATCH (lock:__LiquibaseLock {id: $0}) DELETE lock",
"MATCH (lock:__LiquibaseLock {id: $1}) DELETE lock",
lockId.toString()
));
database.commit();
Expand Down
2 changes: 1 addition & 1 deletion src/test/groovy/liquibase/ext/neo4j/CypherRunner.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class CypherRunner implements AutoCloseable {
def parameters = statement.parameters
Map<String, Object> indexedMap = IntStream.range(0, parameters.size())
.boxed()
.collect(Collectors.toMap((Integer index) -> index.toString(), (Integer index) -> parameters.get(index)))
.collect(Collectors.toMap((Integer index) -> (index+1).toString(), (Integer index) -> parameters.get(index)))
run(statement.sql, indexedMap)
return
}
Expand Down
Loading