Skip to content

Commit 9a2e644

Browse files
id keeps on giving.
1 parent 248140a commit 9a2e644

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/main/java/org/springframework/data/neo4j/core/ResultSummaries.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package org.springframework.data.neo4j.core;
1717

18+
import java.util.List;
1819
import java.util.function.Consumer;
1920
import java.util.function.Predicate;
2021
import java.util.regex.Pattern;
@@ -68,11 +69,12 @@ final class ResultSummaries {
6869
private static final LogAccessor cypherSchemaNotificationLog = new LogAccessor(
6970
LogFactory.getLog("org.springframework.data.neo4j.cypher.schema"));
7071

71-
private static final Pattern DEPRECATED_ID_PATTERN = Pattern
72-
.compile("(?im)The query used a deprecated function[.:] \\(?[`']id.+");
73-
74-
private static final Pattern DEPRECATED_ID_PATTERN_GQL = Pattern
75-
.compile("(?im).*id is deprecated and will be removed without a replacement\\.");
72+
private static final List<Pattern> STUFF_THAT_MIGHT_INFORM_THAT_THE_ID_FUNCTION_IS_PROBLEMATIC = Stream.of(
73+
"(?im)The query used a deprecated function[.:] \\(?[`']id.+",
74+
"(?im).*id is deprecated and will be removed without a replacement\\.",
75+
"(?im).*feature deprecated with replacement\\. id is deprecated\\. It is replaced by elementId or consider using an application-generated id\\.")
76+
.map(Pattern::compile)
77+
.toList();
7678

7779
private ResultSummaries() {
7880
}
@@ -103,8 +105,8 @@ private static void logNotifications(ResultSummary resultSummary) {
103105
.filter(cat -> cat == NotificationClassification.UNRECOGNIZED
104106
|| cat == NotificationClassification.DEPRECATION)
105107
.isPresent()
106-
&& (DEPRECATED_ID_PATTERN.matcher(notification.statusDescription()).matches()
107-
|| DEPRECATED_ID_PATTERN_GQL.matcher(notification.statusDescription()).matches());
108+
&& STUFF_THAT_MIGHT_INFORM_THAT_THE_ID_FUNCTION_IS_PROBLEMATIC.stream()
109+
.anyMatch(p -> p.matcher(notification.statusDescription()).matches());
108110
}
109111
finally {
110112
Neo4jClient.SUPPRESS_ID_DEPRECATIONS.setRelease(supressIdDeprecations);

src/test/java/org/springframework/data/neo4j/integration/misc/IdLoggingIT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package org.springframework.data.neo4j.integration.misc;
1717

18+
import java.util.Set;
1819
import java.util.function.Predicate;
1920

2021
import ch.qos.logback.classic.Level;
@@ -72,8 +73,8 @@ void idWarningShouldBeSuppressed(LogbackCapture logbackCapture, @Autowired Neo4j
7273
assertThatCode(() -> neo4jClient.query("CREATE (n:XXXIdTest) RETURN id(n)").fetch().all())
7374
.doesNotThrowAnyException();
7475
// 01N42 is the old polyfill (spotted in 5.21)
75-
Predicate<String> stringPredicate = msg -> msg.contains("01N00") || msg.contains("01N02")
76-
|| msg.contains("01N42");
76+
var expectedCodes = Set.of("01N00", "01N01", "01N02", "01N42");
77+
Predicate<String> stringPredicate = msg -> expectedCodes.stream().anyMatch(msg::contains);
7778

7879
if (enabled == null || enabled) {
7980
assertThat(logbackCapture.getFormattedMessages()).noneMatch(stringPredicate);

0 commit comments

Comments
 (0)