diff --git a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.11.xml b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.11.xml index 83d3596f2a..4fc256f136 100644 --- a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.11.xml +++ b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.11.xml @@ -18189,6 +18189,17 @@ CREATE TABLE book_to_book_store ( scripts src/main/resources/database.sql + + + + sort + semantic + @@ -18202,9 +18213,13 @@ CREATE TABLE book_to_book_store ( .withGenerator(new Generator( .withDatabase(new Database() .withName("org.jooq.util.ddl.DDLDatabase") - .withProperties(new Property() - .withKey("scripts") - .withValue("src/main/resources/database.sql")))));]]> + .withProperties( + new Property() + .withKey("scripts") + .withValue("src/main/resources/database.sql"), + new Property() + .withKey("sort") + .withValue("semantic")))));]]>

Gradle configuration @@ -18219,6 +18234,10 @@ CREATE TABLE book_to_book_store ( key = 'scripts' value = 'src/main/resources/database.sql' } + property { + key = 'sort' + value = 'semantic' + } } } } diff --git a/jOOQ-meta-extensions/src/main/java/org/jooq/util/ddl/DDLDatabase.java b/jOOQ-meta-extensions/src/main/java/org/jooq/util/ddl/DDLDatabase.java index 3797a3744b..08df05fd2b 100644 --- a/jOOQ-meta-extensions/src/main/java/org/jooq/util/ddl/DDLDatabase.java +++ b/jOOQ-meta-extensions/src/main/java/org/jooq/util/ddl/DDLDatabase.java @@ -48,6 +48,7 @@ import java.sql.Connection; import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Comparator; import java.util.Iterator; import java.util.List; import java.util.Properties; @@ -89,12 +90,26 @@ public class DDLDatabase extends H2Database { private Connection connection; private DSLContext ctx; + private Comparator fileComparator; @Override protected DSLContext create0() { if (connection == null) { String scripts = getProperties().getProperty("scripts"); String encoding = getProperties().getProperty("encoding", "UTF-8"); + String sort = getProperties().getProperty("sort", "semantic").toLowerCase(); + + if ("alphanumeric".equals(sort)) + fileComparator = new Comparator() { + @Override + public int compare(File o1, File o2) { + return o1.compareTo(o2); + } + }; + else if ("none".equals(sort)) + fileComparator = null; + else + fileComparator = FileComparator.INSTANCE; if (isBlank(scripts)) { scripts = ""; @@ -169,7 +184,8 @@ public class DDLDatabase extends H2Database { File[] files = file.listFiles(); if (files != null) { - Arrays.sort(files, FileComparator.INSTANCE); + if (fileComparator != null) + Arrays.sort(files, fileComparator); for (File f : files) load(encoding, f, pattern);