Fix SQL parser skipping statements that follow comment lines
All checks were successful
CI / build (push) Successful in 47s
CI / docker (push) Successful in 41s
CI / deploy (push) Successful in 10s

split(';') produced chunks starting with '--' comment lines, causing
the startsWith('--') check to skip the entire CREATE TABLE statement
for route_executions. Now strips comment lines before splitting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-03-12 21:55:36 +01:00
parent ce0eb58b0c
commit a2cbd115ee

View File

@@ -66,9 +66,13 @@ public class ClickHouseConfig {
// Apply schema files using fully qualified table names // Apply schema files using fully qualified table names
for (String schemaFile : SCHEMA_FILES) { for (String schemaFile : SCHEMA_FILES) {
String sql = new ClassPathResource(schemaFile).getContentAsString(StandardCharsets.UTF_8); String sql = new ClassPathResource(schemaFile).getContentAsString(StandardCharsets.UTF_8);
for (String statement : sql.split(";")) { // Strip comment lines before splitting into statements
String stripped = sql.lines()
.filter(line -> !line.trim().startsWith("--"))
.collect(java.util.stream.Collectors.joining("\n"));
for (String statement : stripped.split(";")) {
String trimmed = statement.trim(); String trimmed = statement.trim();
if (!trimmed.isEmpty() && !trimmed.startsWith("--")) { if (!trimmed.isEmpty()) {
stmt.execute(trimmed); stmt.execute(trimmed);
} }
} }