Skip to content

Commit 11374c6

Browse files
committed
Merge branch 'DBTOOLS-1755_version_12' into 'master'
DBTOOLS-1755 version 12 See merge request codekeeper/pgcodekeeper-cli!16
2 parents b71f74a + 9a469d8 commit 11374c6

File tree

7 files changed

+70
-412
lines changed

7 files changed

+70
-412
lines changed

CHANGELOG.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,23 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1313

1414
### Fixed
1515

16+
## [12.0.0] - 2025-10-15
17+
18+
### Added
19+
20+
- Added support for PostgreSQL 18.
21+
- Added formatting of the SELECT part of VIEW objects when reading from the database for ClickHouse.
22+
23+
### Changed
24+
25+
### Fixed
26+
27+
- Fixed code generation for columns with Nullable values in ClickHouse.
28+
1629
### Removed
1730

31+
- Removed support for MS SQL versions below 2017.
32+
- Removed support for PostgreSQL versions below 14.
1833
- Removed deprecated `--parse`, `--graph`, `--insert` parameters.
1934

2035
## [11.2.0] - 2025-09-23
@@ -48,6 +63,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
4863
- Fixed a bug with the settings when saving objects to a project.
4964
- Fixed false differences when ignoring table column order.
5065

51-
[Unreleased]: https://github.com/pgcodekeeper/pgcodekeeper-cli/compare/v11.2.0...HEAD
66+
[Unreleased]: https://github.com/pgcodekeeper/pgcodekeeper-cli/compare/v12.0.0...HEAD
67+
[12.0.0]: https://github.com/pgcodekeeper/pgcodekeeper-cli/compare/v11.2.0...v12.0.0
5268
[11.2.0]: https://github.com/pgcodekeeper/pgcodekeeper-cli/compare/v11.0.0...v11.2.0
5369
[11.0.0]: https://github.com/pgcodekeeper/pgcodekeeper-cli/releases/tag/v11.0.0

CHANGELOG.ru.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,21 @@
1313

1414
### Исправлено
1515

16+
## [12.0.0] - 2025-10-15
17+
18+
### Добавлено
19+
20+
- Добавлена поддержка PostgreSQL 18.
21+
- Добавлено форматирование SELECT части объектов VIEW при чтении из базы данных для ClickHouse.
22+
23+
### Исправлено
24+
25+
- Исправлена генерация кода для колонок c Nullable значениями в ClickHouse.
26+
1627
### Удалено
1728

29+
- Прекращена поддержка версий MS SQL ниже 2017.
30+
- Прекращена поддержка версий PostgreSQL ниже 14.
1831
- Удалены устаревшие параметры `--parse`, `--graph`, `--insert`.
1932

2033
## [11.2.0] - 2025-09-23
@@ -48,6 +61,7 @@
4861
- Исправлена ошибка с работой настроек при сохранении объектов в проект.
4962
- Исправлены ложные различия при игнорировании порядка колонок таблицы.
5063

51-
[Новое]: https://github.com/pgcodekeeper/pgcodekeeper-cli/compare/v11.2.0...HEAD
64+
[Новое]: https://github.com/pgcodekeeper/pgcodekeeper-cli/compare/v12.0.0...HEAD
65+
[12.0.0]: https://github.com/pgcodekeeper/pgcodekeeper-cli/compare/v11.2.0...v12.0.0
5266
[11.2.0]: https://github.com/pgcodekeeper/pgcodekeeper-cli/compare/v11.0.0...v11.2.0
5367
[11.0.0]: https://github.com/pgcodekeeper/pgcodekeeper-cli/releases/tag/v11.0.0

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<modelVersion>4.0.0</modelVersion>
88
<groupId>org.pgcodekeeper</groupId>
99
<artifactId>pgcodekeeper-cli</artifactId>
10-
<version>11.2.0</version>
10+
<version>12.0.0</version>
1111
<packaging>jar</packaging>
1212

1313
<name>pgcodekeeper-cli</name>
@@ -47,7 +47,7 @@
4747
<dependency>
4848
<groupId>org.pgcodekeeper</groupId>
4949
<artifactId>pgcodekeeper-core</artifactId>
50-
<version>11.2.0</version>
50+
<version>12.0.0</version>
5151
</dependency>
5252
<dependency>
5353
<groupId>ch.qos.logback</groupId>

src/main/java/org/pgcodekeeper/cli/Application.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
import org.pgcodekeeper.cli.localizations.Messages;
2424
import org.pgcodekeeper.core.DangerStatement;
2525
import org.pgcodekeeper.core.PgCodekeeperException;
26+
import org.pgcodekeeper.core.database.base.jdbc.AbstractJdbcConnector;
2627
import org.pgcodekeeper.core.loader.JdbcRunner;
2728
import org.pgcodekeeper.core.loader.TokenLoader;
28-
import org.pgcodekeeper.core.loader.UrlJdbcConnector;
2929
import org.pgcodekeeper.core.model.graph.DepcyFinder;
3030
import org.pgcodekeeper.core.model.graph.InsertWriter;
3131
import org.pgcodekeeper.core.parsers.antlr.base.ScriptParser;
@@ -148,7 +148,7 @@ private static boolean diff(CliArgs arguments)
148148
}
149149

150150
LOG.info(Messages.Main_log_apply_migration_script);
151-
new JdbcRunner().runBatches(new UrlJdbcConnector(url), parser.batch(), null);
151+
new JdbcRunner().runBatches(getConnector(arguments, url), parser.batch(), null);
152152
} else if (encodedWriter == null) {
153153
writeToConsole(text);
154154
}
@@ -205,7 +205,7 @@ private static boolean insert(CliArgs arguments)
205205
String url = arguments.getRunOnDb();
206206
if (url != null) {
207207
LOG.info(Messages.Main_log_run_insert_data);
208-
new JdbcRunner().runBatches(new UrlJdbcConnector(url),
208+
new JdbcRunner().runBatches(getConnector(arguments, url),
209209
new ScriptParser("CLI", script, arguments).batch(), null); //$NON-NLS-1$
210210
} else if (pw == null) {
211211
writeToConsole(script);
@@ -216,6 +216,10 @@ private static boolean insert(CliArgs arguments)
216216
return true;
217217
}
218218

219+
private static AbstractJdbcConnector getConnector(CliArgs arguments, String url) {
220+
return arguments.getProvider().getJdbcConnector(url);
221+
}
222+
219223
private static boolean graph(CliArgs arguments) throws IOException, InterruptedException {
220224
var diff = new PgDiffCli(arguments);
221225
AbstractDatabase d;

src/main/java/org/pgcodekeeper/cli/CliArgs.java

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@
2424
import org.pgcodekeeper.core.Consts;
2525
import org.pgcodekeeper.core.DangerStatement;
2626
import org.pgcodekeeper.core.DatabaseType;
27+
import org.pgcodekeeper.core.database.base.IDatabaseProvider;
28+
import org.pgcodekeeper.core.database.ch.ChDatabaseProvider;
29+
import org.pgcodekeeper.core.database.ms.MsDatabaseProvider;
30+
import org.pgcodekeeper.core.database.pg.PgDatabaseProvider;
2731
import org.pgcodekeeper.core.formatter.FormatConfiguration;
28-
import org.pgcodekeeper.core.loader.UrlJdbcConnector;
2932
import org.pgcodekeeper.core.model.difftree.DbObjType;
3033
import org.pgcodekeeper.core.settings.ISettings;
3134

@@ -56,6 +59,8 @@ enum CliMode {
5659
private static final String URL_START_JDBC = "jdbc:"; //$NON-NLS-1$
5760
private static final int DEFAULT_DEPTH = 10;
5861

62+
private IDatabaseProvider provider;
63+
5964
// SONAR-OFF
6065
{
6166
// this was moved to initializer to avoid the IDE making the field "final" on-save
@@ -520,6 +525,10 @@ public FormatConfiguration getFormatConfiguration() {
520525
return null;
521526
}
522527

528+
public IDatabaseProvider getProvider() {
529+
return provider;
530+
}
531+
523532
@Override
524533
public CliArgs copy() {
525534
var args = new CliArgs();
@@ -577,6 +586,7 @@ public CliArgs copy() {
577586
args.usingTypeCastOff = usingTypeCastOff;
578587
args.verifyRuleSetPath = verifyRuleSetPath;
579588
args.verifySources = verifySources;
589+
args.provider = provider;
580590
return args;
581591
}
582592

@@ -629,9 +639,18 @@ public boolean parse(String[] args) throws CmdLineException {
629639
oldSrc = outputTarget;
630640
}
631641

642+
createProvider();
632643
return true;
633644
}
634645

646+
private void createProvider() {
647+
provider = switch (dbType) {
648+
case PG -> new PgDatabaseProvider();
649+
case MS -> new MsDatabaseProvider();
650+
case CH -> new ChDatabaseProvider();
651+
};
652+
}
653+
635654
private void checkParams() throws CmdLineException {
636655
if (CliMode.VERIFY == mode) {
637656
if (verifyRuleSetPath == null) {
@@ -651,39 +670,24 @@ private void checkParams() throws CmdLineException {
651670
if (dbType == DatabaseType.PG && addTransaction && concurrentlyMode) {
652671
badArgs(Messages.CliArgs_error_concurrently_mode_wrong_option);
653672
}
654-
655-
DatabaseType typeNewSrc = getDatabaseTypeFromSource(newSrc);
656-
DatabaseType typeOldSrc = getDatabaseTypeFromSource(oldSrc);
657-
if (typeOldSrc != typeNewSrc) {
658-
badArgs(String.format(Messages.CliArgs_error_different_types, typeNewSrc.toString(),
659-
typeOldSrc.toString()));
660-
}
661673
if (runOnTarget && !oldSrc.startsWith(URL_START_JDBC)) {
662674
badArgs(Messages.CliArgs_error_target_non_db);
663675
}
664676
if (runOnDb != null && !runOnDb.startsWith(URL_START_JDBC)) {
665677
badArgs(Messages.CliArgs_error_run_on_non_jdbc);
666678
}
667-
} else {
668-
DatabaseType typeNewSrc = getDatabaseTypeFromSource(newSrc);
669-
if (dbType != typeNewSrc) {
670-
badArgs(String.format(Messages.CliArgs_error_message_cannot_database_with_project,
671-
typeNewSrc.toString(), dbType.toString()));
679+
} else if (CliMode.INSERT == mode) {
680+
if (!newSrc.startsWith(URL_START_JDBC)) {
681+
badArgs(Messages.CliArgs_error_source_non_db);
672682
}
673-
if (CliMode.PARSE == mode && outputTarget == null) {
674-
badArgs(Messages.CliArgs_error_argument_null.formatted("\"-o (--output)\"")); //$NON-NLS-1$
683+
if (runOnDb != null && !runOnDb.startsWith(URL_START_JDBC)) {
684+
badArgs(Messages.CliArgs_error_run_on_non_jdbc);
675685
}
676-
if (CliMode.INSERT == mode) {
677-
if (!newSrc.startsWith(URL_START_JDBC)) {
678-
badArgs(Messages.CliArgs_error_source_non_db);
679-
}
680-
if (runOnDb != null && !runOnDb.startsWith(URL_START_JDBC)) {
681-
badArgs(Messages.CliArgs_error_run_on_non_jdbc);
682-
}
683-
if (insertName == null) {
684-
badArgs(Messages.CliArgs_error_argument_null.formatted("\"--insert-name\"")); //$NON-NLS-1$
685-
}
686+
if (insertName == null) {
687+
badArgs(Messages.CliArgs_error_argument_null.formatted("\"--insert-name\"")); //$NON-NLS-1$
686688
}
689+
} else if (CliMode.PARSE == mode && outputTarget == null) {
690+
badArgs(Messages.CliArgs_error_argument_null.formatted("\"-o (--output)\"")); //$NON-NLS-1$
687691
}
688692
}
689693

@@ -757,13 +761,6 @@ private void badArgs(String message) throws CmdLineException {
757761
throw new CmdLineException(null, message, null);
758762
}
759763

760-
private DatabaseType getDatabaseTypeFromSource(String src) {
761-
if (src != null && src.startsWith(URL_START_JDBC)) {
762-
return UrlJdbcConnector.getDatabaseTypeFromUrl(src);
763-
}
764-
return dbType;
765-
}
766-
767764
private void printUsage() {
768765
// fix defaults for options like help and other 0-arg booleans
769766
OptionHandlerRegistry.getRegistry().registerHandler(Boolean.class, BooleanNoDefOptionHandler.class);

src/test/java/org/pgcodekeeper/cli/CliArgsTest.java

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ class CliArgsTest {
3333
"--mode PARSE -s filename -t filename -o filename;" +
3434
"-t (--target) cannot be used with --mode PARSE option",
3535

36-
"--mode graph --graph-name public.test --db-type MS jdbc:postgresql:q;" +
37-
"Cannot work with PG database as MS project.",
38-
39-
"--mode graph --graph-name dbo.test jdbc:sqlserver:f;"
40-
+ "Cannot work with MS database as PG project.",
41-
4236
"--mode graph --graph-name public.test jdbc:postgresql:q jdbc:postgresql:q2;"
4337
+ "-t (--target) cannot be used with --mode GRAPH option",
4438

@@ -54,84 +48,6 @@ class CliArgsTest {
5448
"jdbc:postgresql:q jdbc:postgresql:q2 -X -C;"
5549
+ "-C (--concurrently-mode) cannot be used with the option(s) -X (--add-transaction) for PostgreSQL.",
5650

57-
"jdbc:sqlserver:f jdbc:postgresql:q2;"
58-
+ "Source (MS) and target (PG) are of different types, possibly missing --db-type parameter.",
59-
60-
"jdbc:postgresql:q2 jdbc:sqlserver:f;"
61-
+ "Source (PG) and target (MS) are of different types, possibly missing --db-type parameter.",
62-
63-
"jdbc:sqlserver:f jdbc:ch:c;"
64-
+ "Source (MS) and target (CH) are of different types, possibly missing --db-type parameter.",
65-
66-
"jdbc:ch:c jdbc:sqlserver:f;"
67-
+ "Source (CH) and target (MS) are of different types, possibly missing --db-type parameter.",
68-
69-
"jdbc:sqlserver:f jdbc:clickhouse:c;"
70-
+ "Source (MS) and target (CH) are of different types, possibly missing --db-type parameter.",
71-
72-
"jdbc:clickhouse:c jdbc:sqlserver:f;"
73-
+ "Source (CH) and target (MS) are of different types, possibly missing --db-type parameter.",
74-
75-
"jdbc:postgresql:q2 jdbc:ch:c;"
76-
+ "Source (PG) and target (CH) are of different types, possibly missing --db-type parameter.",
77-
78-
"jdbc:ch:c jdbc:postgresql:q2;"
79-
+ "Source (CH) and target (PG) are of different types, possibly missing --db-type parameter.",
80-
81-
"jdbc:postgresql:q2 jdbc:clickhouse:c;"
82-
+ "Source (PG) and target (CH) are of different types, possibly missing --db-type parameter.",
83-
84-
"jdbc:clickhouse:c jdbc:postgresql:q2;"
85-
+ "Source (CH) and target (PG) are of different types, possibly missing --db-type parameter.",
86-
87-
"jdbc:sqlserver:f filename;"
88-
+ "Source (MS) and target (PG) are of different types, possibly missing --db-type parameter.",
89-
90-
"filename jdbc:sqlserver:f;"
91-
+ "Source (PG) and target (MS) are of different types, possibly missing --db-type parameter.",
92-
93-
"jdbc:sqlserver:f filename --db-type CH;"
94-
+ "Source (MS) and target (CH) are of different types, possibly missing --db-type parameter.",
95-
96-
"filename jdbc:sqlserver:f --db-type CH;"
97-
+ "Source (CH) and target (MS) are of different types, possibly missing --db-type parameter.",
98-
99-
"jdbc:postgresql:q2 filename --db-type MS;"
100-
+ "Source (PG) and target (MS) are of different types, possibly missing --db-type parameter.",
101-
102-
"filename jdbc:postgresql:q2 --db-type MS;"
103-
+ "Source (MS) and target (PG) are of different types, possibly missing --db-type parameter.",
104-
105-
"jdbc:postgresql:q2 filename --db-type CH;"
106-
+ "Source (PG) and target (CH) are of different types, possibly missing --db-type parameter.",
107-
108-
"filename jdbc:postgresql:q2 --db-type CH;"
109-
+ "Source (CH) and target (PG) are of different types, possibly missing --db-type parameter.",
110-
111-
"filename jdbc:ch:c;"
112-
+ "Source (PG) and target (CH) are of different types, possibly missing --db-type parameter.",
113-
114-
"jdbc:ch:c filename;"
115-
+ "Source (CH) and target (PG) are of different types, possibly missing --db-type parameter.",
116-
117-
"filename jdbc:ch:c --db-type MS;"
118-
+ "Source (MS) and target (CH) are of different types, possibly missing --db-type parameter.",
119-
120-
"jdbc:ch:c filename --db-type MS;"
121-
+ "Source (CH) and target (MS) are of different types, possibly missing --db-type parameter.",
122-
123-
"filename jdbc:clickhouse:c;"
124-
+ "Source (PG) and target (CH) are of different types, possibly missing --db-type parameter.",
125-
126-
"jdbc:clickhouse:c filename;"
127-
+ "Source (CH) and target (PG) are of different types, possibly missing --db-type parameter.",
128-
129-
"filename jdbc:clickhouse:c --db-type MS;"
130-
+ "Source (MS) and target (CH) are of different types, possibly missing --db-type parameter.",
131-
132-
"jdbc:clickhouse:c filename --db-type MS;"
133-
+ "Source (CH) and target (MS) are of different types, possibly missing --db-type parameter.",
134-
13551
"-r filename filename;"
13652
+ "Script can be applied only to database.",
13753

0 commit comments

Comments
 (0)