summaryrefslogtreecommitdiff
path: root/src/test/java/org
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-12-05 20:16:19 +0000
committerMichael Williamson <mike@zwobble.org>2026-12-05 20:16:19 +0000
commit2a5290cb52b6d95f9461e4bcdfffc4c56c573361 (patch)
tree5707e5cff5787de6fe21a31b59a6a0a5454e2159 /src/test/java/org
parent8b6c82d1114320eeca2695f4e2c1db9eca4ab361 (diff)
Add column reference to SQL AST
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriterTests.java12
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlColumnReferenceMatcher.java47
2 files changed, 59 insertions, 0 deletions
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriterTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriterTests.java
index 4f9771a..2a96c4b 100644
--- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriterTests.java
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriterTests.java
@@ -215,6 +215,18 @@ public class SqlWriterTests {
}
@Test
+ public void columnReference() throws IOException {
+ var sql = SqlColumnReference.arbitrary()
+ .withRelationName(id("authors"))
+ .withColumnName(id("name"))
+ .build();
+
+ var string = write(writer -> writer.writeExpression(sql));
+
+ assertThat(string, equalTo("authors.name"));
+ }
+
+ @Test
public void intLiteral() throws IOException {
var sql = SqlIntLiteral.arbitrary()
.withValue(42)
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlColumnReferenceMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlColumnReferenceMatcher.java
new file mode 100644
index 0000000..35916c0
--- /dev/null
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlColumnReferenceMatcher.java
@@ -0,0 +1,47 @@
+// Generated by hobgoblin.
+
+package org.zwobble.hobgoblin.compiler.output.lang.sql.ast;
+
+// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlColumnReferenceMatcher imports
+// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlColumnReferenceMatcher imports
+
+public final class SqlColumnReferenceMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> {
+ public static org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlColumnReferenceMatcher isSqlColumnReference() {
+ return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlColumnReferenceMatcher(java.util.List.of());
+ }
+
+ private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlColumnReference>> submatchers;
+
+ private SqlColumnReferenceMatcher(
+ java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlColumnReference>> submatchers
+ ) {
+ this.submatchers = submatchers;
+ }
+
+ public org.zwobble.precisely.MatchResult match(java.lang.Object actual) {
+ return this.toMatcher().match(actual);
+ }
+
+ public org.zwobble.precisely.TextTree describe() {
+ return this.toMatcher().describe();
+ }
+
+ private org.zwobble.precisely.Matcher<java.lang.Object> toMatcher() {
+ return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlColumnReference.class, this.submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlColumnReferenceMatcher withRelationName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIdentifier> relationName) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlColumnReference>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("relationName", org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlColumnReference::relationName, (org.zwobble.precisely.Matcher) relationName));
+ return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlColumnReferenceMatcher(submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlColumnReferenceMatcher withColumnName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIdentifier> columnName) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlColumnReference>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("columnName", org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlColumnReference::columnName, (org.zwobble.precisely.Matcher) columnName));
+ return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlColumnReferenceMatcher(submatchers);
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlColumnReferenceMatcher body
+ // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlColumnReferenceMatcher body
+}