Skip to content

Commit aef747e

Browse files
committed
Merge branch 'DBTOOLS-2027_fix_override' into 'master'
DBTOOLS-2027 disabled loading of the OVERRIDES directory for libraries See merge request codekeeper/pgcodekeeper-core!248
2 parents cbf71e6 + 8d71e50 commit aef747e

12 files changed

Lines changed: 52 additions & 28 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1111

1212
### Changed
1313

14+
- Disabled loading of the OVERRIDES directory for libraries to restore the behavior typical before version 14.0.0.
15+
1416
### Fixed
1517

1618
- Fixed incorrect error on parallel database load failure.
19+
- Fixed an error when calling the project load API method without specifying the library load directory.
1720

1821
## [14.1.0] - 2026-03-18
1922

CHANGELOG.ru.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111

1212
### Изменено
1313

14+
- Отключена загрузка директории OVERRIDES у библиотек для восстановления поведения, характерного до версии 14.0.0.
15+
1416
### Исправлено
1517

1618
- Исправлена некорректная ошибка при сбое параллельной загрузки БД.
19+
- Исправлена ошибка при вызове API метода загрузки проекта без указания директории загрузки библиотек.
1720

1821
## [14.1.0] - 2026-03-18
1922

src/main/java/org/pgcodekeeper/core/database/base/loader/AbstractLibraryLoader.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@
4444
*/
4545
public abstract class AbstractLibraryLoader<T extends IDatabase> extends AbstractLoader<T> {
4646

47+
private static final String LOG_DIR = ".pgcodekeeper-core";
48+
private static final String DEPS_DIR = "dependencies";
49+
private static final Path META_PATH = Paths.get(System.getProperty("user.home"), LOG_DIR, DEPS_DIR);
50+
4751
protected final T database;
4852
protected final Path metaPath;
4953
protected final Set<String> loadedPaths;
@@ -54,7 +58,7 @@ protected AbstractLibraryLoader(T database, Path metaPath, Set<String> loadedPat
5458
DiffSettings diffSettings) {
5559
super(diffSettings, "");
5660
this.database = database;
57-
this.metaPath = metaPath;
61+
this.metaPath = metaPath != null ? metaPath : META_PATH;
5862
this.loadedPaths = loadedPaths;
5963
}
6064

src/main/java/org/pgcodekeeper/core/database/base/loader/AbstractProjectLoader.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,12 @@ public T loadInternal() throws InterruptedException, IOException {
8282
IMonitor.checkCancelled(getMonitor());
8383
finishLoaders();
8484
IMonitor.checkCancelled(getMonitor());
85-
loadLibraries(db);
86-
IMonitor.checkCancelled(getMonitor());
87-
loadOverrides(db);
85+
if (!isLib) {
86+
loadLibraries(db);
87+
IMonitor.checkCancelled(getMonitor());
88+
loadOverrides(db);
89+
IMonitor.checkCancelled(getMonitor());
90+
}
8891
return db;
8992
}
9093

@@ -190,7 +193,7 @@ private void replacePrivileges(AbstractStatement st, StatementOverride override)
190193
private void loadLibraries(T db) throws IOException, InterruptedException {
191194
var libraryLoader = createLibraryLoader(db);
192195

193-
if (!isLib && !diffSettings.getSettings().isDisableAutoLoad()) {
196+
if (!diffSettings.getSettings().isDisableAutoLoad()) {
194197
// check project libraries
195198
Path depsFile = dirPath.resolve(LibraryXmlStore.FILE_NAME);
196199
if (Files.isRegularFile(depsFile)) {

src/test/java/org/pgcodekeeper/core/TestUtils.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
import java.nio.charset.StandardCharsets;
2222
import java.nio.file.Path;
2323
import java.nio.file.Paths;
24+
import java.util.List;
2425
import java.util.Locale;
26+
import java.util.stream.Collectors;
27+
2528
import org.junit.jupiter.api.Assertions;
2629

2730
public final class TestUtils {
@@ -56,6 +59,14 @@ public static void assertIgnoreNewLines(String expected, String actual) {
5659
actual.lines());
5760
}
5861

62+
public static void assertErrors(List<Object> errors) {
63+
var errorsString = errors.stream()
64+
.map(Object::toString)
65+
.collect(Collectors.joining(System.lineSeparator()));
66+
67+
Assertions.assertEquals("", errorsString);
68+
}
69+
5970
private TestUtils() {
6071
}
6172
}

src/test/java/org/pgcodekeeper/core/api/PgCodeKeeperApiTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ void diffTest(String testName) throws IOException, InterruptedException {
5959
String actual = PgCodeKeeperApi.diff(provider, oldDbLoader, newDbLoader, diffSettings);
6060

6161
TestUtils.assertIgnoreNewLines(expectedDiff, actual);
62+
TestUtils.assertErrors(diffSettings.getErrors());
6263
}
6364

6465

@@ -78,6 +79,7 @@ void loaderTest(String testName, boolean parallelLoad) throws IOException, Inter
7879
String actual = PgCodeKeeperApi.diff(provider, oldDbLoader, newDbLoader, diffSetts);
7980

8081
TestUtils.assertIgnoreNewLines(expectedDiff, actual);
82+
TestUtils.assertErrors(diffSettings.getErrors());
8183
}
8284

8385
@ParameterizedTest
@@ -94,6 +96,7 @@ void diffWithIgnoreListTest(String testName) throws IOException, InterruptedExce
9496
String actual = PgCodeKeeperApi.diff(provider, oldDbLoader, newDbLoader, diffSettings);
9597

9698
TestUtils.assertIgnoreNewLines(expectedDiff, actual);
99+
TestUtils.assertErrors(diffSettings.getErrors());
97100
}
98101

99102
@Test
@@ -106,6 +109,7 @@ void exportTest(@TempDir Path tempDir) throws IOException, InterruptedException
106109
PgCodeKeeperApi.exportToProject(provider, null, loader, tempDir, diffSettings);
107110

108111
assertFileContent(exportedTableFile, expectedContent);
112+
TestUtils.assertErrors(diffSettings.getErrors());
109113
}
110114

111115
@Test
@@ -121,6 +125,7 @@ void exportWithIgnoreListTest(@TempDir Path tempDir) throws IOException, Interru
121125

122126
assertFileContent(exportedTableFile, expectedContent);
123127
assertFalse(Files.exists(ignoredTableFile));
128+
TestUtils.assertErrors(diffSettings.getErrors());
124129
}
125130

126131
@Test
@@ -140,6 +145,7 @@ void updateProjectTest(@TempDir Path tempDir) throws IOException, InterruptedExc
140145
// Verify first table was removed and second table was updated
141146
assertFalse(Files.exists(firstTableFile));
142147
assertFileContent(secondTableFile, expectedContent);
148+
TestUtils.assertErrors(diffSettings.getErrors());
143149
}
144150

145151
@Test
@@ -163,6 +169,7 @@ void updateProjectWithIgnoreListTest(@TempDir Path tempDir) throws IOException,
163169
// Verify both tables exist and have correct content
164170
assertFileContent(firstTableFile, expectedFirstTableContent);
165171
assertFileContent(secondTableFile, expectedSecondTableContent);
172+
TestUtils.assertErrors(diffSettings.getErrors());
166173
}
167174

168175
private void setupUpdateProjectStructure(Path tempDir) throws IOException {

src/test/java/org/pgcodekeeper/core/it/IntegrationTestUtils.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import java.nio.file.Files;
3838
import java.nio.file.Path;
3939
import java.util.*;
40-
import java.util.stream.Collectors;
4140

4241
public final class IntegrationTestUtils {
4342

@@ -69,18 +68,10 @@ public static IDatabase loadTestDump(IDatabaseProvider databaseProvider, String
6968
FullAnalyze.fullAnalyze(db, diffSettings.getErrors());
7069
}
7170

72-
assertErrors(diffSettings.getErrors());
71+
TestUtils.assertErrors(diffSettings.getErrors());
7372
return db;
7473
}
7574

76-
public static void assertErrors(List<Object> errors) {
77-
var errorsString = errors.stream()
78-
.map(Object::toString)
79-
.collect(Collectors.joining(System.lineSeparator()));
80-
81-
Assertions.assertEquals("", errorsString);
82-
}
83-
8475
public static void assertDiffSame(IDatabaseProvider provider, IDatabase db, String template,
8576
DiffSettings diffSettings)
8677
throws IOException, InterruptedException {

src/test/java/org/pgcodekeeper/core/it/loader/pg/PgProjectLoaderTest.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,7 @@ void testProjectLoaderWithoutAutoLoad(@TempDir Path dir) throws IOException, Int
129129
assertTrue(result, "Ignored schemas not loaded");
130130
assertTrue(diffSettings.getIgnoreList().getList().isEmpty());
131131

132-
var libTableRef = new ObjectReference("public", "lib_first_table", DbObjType.TABLE);
133-
var libTable = db.getStatement(libTableRef);
134-
135-
Assertions.assertNull(libTable);
132+
assertNotLoaded(db, "lib_first_table");
136133
}
137134

138135
@Test
@@ -208,9 +205,8 @@ void testProjectLoaderWithIsLibTrue(@TempDir Path dir) throws IOException, Inter
208205
loader.setLib(true);
209206
IDatabase db = loader.load();
210207

211-
var libTableRef = new ObjectReference("public", "lib_first_table", DbObjType.TABLE);
212-
Assertions.assertNull(db.getStatement(libTableRef));
213-
assertLibLoaded(db, "lib_second_table", true);
208+
assertNotLoaded(db, "lib_first_table");
209+
assertNotLoaded(db, "lib_second_table");
214210
}
215211

216212
@Test
@@ -253,6 +249,13 @@ private void assertLibLoaded(IDatabase db, String tableName, boolean isWithPrivi
253249
}
254250
}
255251

252+
private void assertNotLoaded(IDatabase db, String tableName) {
253+
var libTableRef = new ObjectReference("public", tableName, DbObjType.TABLE);
254+
var libTable = db.getStatement(libTableRef);
255+
256+
Assertions.assertNull(libTable);
257+
}
258+
256259
private void createProject(Path dir, DiffSettings diffSettings)
257260
throws IOException, InterruptedException {
258261
IDatabase dbDump = loadTestDump(databaseProvider, RESOURCE_DUMP, IntegrationTestUtils.class, diffSettings);

src/test/java/org/pgcodekeeper/core/it/parser/ch/ChObjReferencesTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void compareChReferences(final String fileNameTemplate) throws IOException, Inte
6565

6666
String actual = IntegrationTestUtils.getRefsAsString(db.getObjReferences()).strip();
6767

68-
IntegrationTestUtils.assertErrors(diffSettings.getErrors());
68+
TestUtils.assertErrors(diffSettings.getErrors());
6969
Assertions.assertEquals(expected, actual);
7070
}
7171
}

src/test/java/org/pgcodekeeper/core/it/parser/ch/ChParserTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.pgcodekeeper.core.FILES_POSTFIX;
3333
import org.pgcodekeeper.core.TestUtils;
3434
import org.pgcodekeeper.core.database.ch.parser.ChParserUtils;
35-
import org.pgcodekeeper.core.it.IntegrationTestUtils;
3635

3736
/**
3837
* Tests for ClickHouse parser rules.
@@ -82,7 +81,7 @@ public void reportAmbiguity(Parser p, DFA dfa, int start,
8281
parser.ch_file();
8382

8483
int count = ambiguity.intValue();
85-
IntegrationTestUtils.assertErrors(errors);
84+
TestUtils.assertErrors(errors);
8685
Assertions.assertEquals(allowedAmbiguity, count,
8786
"File: " + fileNameTemplate + " - ANTLR Ambiguity " + count + " expected " + allowedAmbiguity);
8887
}

0 commit comments

Comments
 (0)