diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-12-05 20:27:52 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-12-05 20:27:52 +0000 |
| commit | 1b1bc8da447447440a214f8bd5a721dd9dc2cf73 (patch) | |
| tree | 44b659126576bef7ef7f91762fd9c97d7851a7b2 | |
| parent | 25ce955d42281d15e87eff14faff08063faeec28 (diff) | |
Reorder fields to match syntax
4 files changed, 33 insertions, 33 deletions
diff --git a/hobgoblin/src/output/lang/sql/ast.hob b/hobgoblin/src/output/lang/sql/ast.hob index 4bd6abb..399a023 100644 --- a/hobgoblin/src/output/lang/sql/ast.hob +++ b/hobgoblin/src/output/lang/sql/ast.hob @@ -25,8 +25,8 @@ struct SqlColumnDefinition { struct SqlSelectStatement { field columns: List[SqlResultColumn]; field from: SqlIdentifier; - field orderBy: List[SqlOrderingTerm]; field where: Option[SqlExpression]; + field orderBy: List[SqlOrderingTerm]; } struct SqlResultColumn { diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/sql/SqlGenerator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/sql/SqlGenerator.java index 1abdccb..3326f04 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/sql/SqlGenerator.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/sql/SqlGenerator.java @@ -113,8 +113,8 @@ public class SqlGenerator { return new SqlSelectStatement( columns, generateTableName(table.name()), - orderBy, - Optional.empty() + Optional.empty(), + orderBy ); } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlSelectStatement.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlSelectStatement.java index f7627a8..681f4c1 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlSelectStatement.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlSelectStatement.java @@ -8,73 +8,73 @@ package org.zwobble.hobgoblin.compiler.output.lang.sql.ast; public record SqlSelectStatement( java.util.List<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn> columns, org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIdentifier from, - java.util.List<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlOrderingTerm> orderBy, - java.util.Optional<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression> where + java.util.Optional<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression> where, + java.util.List<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlOrderingTerm> orderBy ) implements org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlStatement { public static org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(java.util.List.of(), org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIdentifier.arbitrary().build(), java.util.List.of(), java.util.Optional.empty()); + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(java.util.List.of(), org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIdentifier.arbitrary().build(), java.util.Optional.empty(), java.util.List.of()); } public record Builder( java.util.List<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn> columns, org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIdentifier from, - java.util.List<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlOrderingTerm> orderBy, - java.util.Optional<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression> where + java.util.Optional<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression> where, + java.util.List<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlOrderingTerm> orderBy ) implements org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlStatement.Builder { public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement build() { - return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement(columns, from, orderBy, where); + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement(columns, from, where, orderBy); } public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder withColumns(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn> columns) { - return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(columns, from, orderBy, where); + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(columns, from, where, orderBy); } public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder addColumn(org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn column) { var columns = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn>(this.columns); columns.add(column); - return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(columns, from, orderBy, where); + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(columns, from, where, orderBy); } public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder addColumn(org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn.Builder column) { var columns = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn>(this.columns); columns.add(column.build()); - return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(columns, from, orderBy, where); + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(columns, from, where, orderBy); } public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder withFrom(org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIdentifier from) { - return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(columns, from, orderBy, where); + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(columns, from, where, orderBy); } public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder withFrom(org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIdentifier.Builder from) { - return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(columns, from.build(), orderBy, where); + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(columns, from.build(), where, orderBy); + } + + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder withWhere(java.util.Optional<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression> where) { + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(columns, from, where, orderBy); + } + + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder withWhere(org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression where) { + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(columns, from, java.util.Optional.of(where), orderBy); + } + + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder withWhere(org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression.Builder where) { + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(columns, from, java.util.Optional.of(where.build()), orderBy); } public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder withOrderBy(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlOrderingTerm> orderBy) { - return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(columns, from, orderBy, where); + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(columns, from, where, orderBy); } public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder addOrderByElement(org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlOrderingTerm orderByElement) { var orderBy = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlOrderingTerm>(this.orderBy); orderBy.add(orderByElement); - return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(columns, from, orderBy, where); + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(columns, from, where, orderBy); } public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder addOrderByElement(org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlOrderingTerm.Builder orderByElement) { var orderBy = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlOrderingTerm>(this.orderBy); orderBy.add(orderByElement.build()); - return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(columns, from, orderBy, where); - } - - public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder withWhere(java.util.Optional<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression> where) { - return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(columns, from, orderBy, where); - } - - public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder withWhere(org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression where) { - return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(columns, from, orderBy, java.util.Optional.of(where)); - } - - public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder withWhere(org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression.Builder where) { - return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(columns, from, orderBy, java.util.Optional.of(where.build())); + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(columns, from, where, orderBy); } // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder body diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlSelectStatementMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlSelectStatementMatcher.java index 75f6761..a52ed17 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlSelectStatementMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlSelectStatementMatcher.java @@ -42,15 +42,15 @@ public final class SqlSelectStatementMatcher implements org.zwobble.precisely.Ma return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatementMatcher(submatchers); } - public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatementMatcher withOrderBy(org.zwobble.precisely.Matcher<? super java.util.List<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlOrderingTerm>> orderBy) { + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatementMatcher withWhere(org.zwobble.precisely.Matcher<? super java.util.Optional<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression>> where) { var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement>>(this.submatchers); - submatchers.add(org.zwobble.precisely.Matchers.has("orderBy", org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement::orderBy, (org.zwobble.precisely.Matcher) orderBy)); + submatchers.add(org.zwobble.precisely.Matchers.has("where", org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement::where, (org.zwobble.precisely.Matcher) where)); return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatementMatcher(submatchers); } - public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatementMatcher withWhere(org.zwobble.precisely.Matcher<? super java.util.Optional<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression>> where) { + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatementMatcher withOrderBy(org.zwobble.precisely.Matcher<? super java.util.List<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlOrderingTerm>> orderBy) { var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement>>(this.submatchers); - submatchers.add(org.zwobble.precisely.Matchers.has("where", org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement::where, (org.zwobble.precisely.Matcher) where)); + submatchers.add(org.zwobble.precisely.Matchers.has("orderBy", org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement::orderBy, (org.zwobble.precisely.Matcher) orderBy)); return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatementMatcher(submatchers); } |
