[jOOQ/jOOQ#11729] Use text blocks in tests

This commit is contained in:
Lukas Eder 2021-04-16 20:56:08 +02:00
parent 6f6a04dcac
commit 1923468386
5 changed files with 36 additions and 23 deletions

View File

@ -70,12 +70,16 @@ public abstract class GeneratorWriter<W extends GeneratorWriter<W>> {
* A pattern to be used with "list" expressions
*/
private static final Pattern PATTERN_LIST = Pattern.compile(
"\\[" +
"(?:\\[before=([^]]+)])?" +
"(?:\\[separator=([^]]+)])?" +
"(?:\\[after=([^]]+)])?" +
"(?:\\[(.*)])" +
"]", Pattern.DOTALL);
"" +
"\\[\n" +
" (?:\\[before=([^]]+)])?\n" +
" (?:\\[separator=([^]]+)])?\n" +
" (?:\\[after=([^]]+)])?\n" +
" (?:\\[(.*)])\n" +
"]\n" +
"",
Pattern.DOTALL | Pattern.COMMENTS
);
private final Files files;
private final File file;

View File

@ -1795,6 +1795,7 @@ final class AlterTableImpl extends AbstractDDLQuery implements
private final void alterColumnTypeAndNullabilityInBlock(Context<?> ctx) {

View File

@ -136,6 +136,8 @@ final class FetchServerOutputListener extends DefaultExecuteListener {

View File

@ -484,15 +484,17 @@ final class MetaImpl extends AbstractMeta {
ukCache = new LinkedHashMap<>();
dsl().resultQuery(
"select m.tbl_name, m.sql\n"
+ "from sqlite_master as m\n"
+ "where m.type = 'table'\n"
+ "and exists (\n"
+ " select 1\n"
+ " from pragma_index_list(m.name) as il\n"
+ " where il.origin = 'u'\n"
+ ")\n"
+ "order by m.tbl_name"
"" +
"select m.tbl_name, m.sql\n" +
"from sqlite_master as m\n" +
"where m.type = 'table'\n" +
"and exists (\n" +
" select 1\n" +
" from pragma_index_list(m.name) as il\n" +
" where il.origin = 'u'\n" +
")\n" +
"order by m.tbl_name\n" +
""
)
.fetchMap(field("tbl_name", VARCHAR), field("sql", VARCHAR))
.forEach((table, sql) -> {

View File

@ -217,14 +217,18 @@ final class TranslatingMetaProvider implements MetaProvider {
catch (DataAccessException e) {
// [#9138] Make users aware of the new parse ignore comment syntax
log.error("DDL interpretation", "Your SQL string could not be parsed or interpreted. This may have a variety of reasons, including:\n"
+ "- The jOOQ parser doesn't understand your SQL\n"
+ "- The jOOQ DDL interpretation logic (translating to H2) cannot simulate your SQL\n"
+ "\n"
+ "If you think this is a bug or a feature worth requesting, please report it here: https://github.com/jOOQ/jOOQ/issues/new/choose\n"
+ "\n"
+ "As a workaround, you can use the Settings.parseIgnoreComments syntax documented here:\n"
+ "https://www.jooq.org/doc/latest/manual/sql-building/dsl-context/custom-settings/settings-parser/");
log.error("DDL interpretation",
"" +
"Your SQL string could not be parsed or interpreted. This may have a variety of reasons, including:\n" +
"- The jOOQ parser doesn't understand your SQL\n" +
"- The jOOQ DDL interpretation logic (translating to H2) cannot simulate your SQL\n" +
"\n" +
"If you think this is a bug or a feature worth requesting, please report it here: https://github.com/jOOQ/jOOQ/issues/new/choose\n" +
"\n" +
"As a workaround, you can use the Settings.parseIgnoreComments syntax documented here:\n" +
"https://www.jooq.org/doc/latest/manual/sql-building/dsl-context/custom-settings/settings-parser/\n" +
""
);
throw e;
}