summaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-10-13 19:43:04 +0100
committerMichael Williamson <mike@zwobble.org>2026-10-13 19:43:04 +0100
commit3afb8859dabdaaa81a6bbbe530d75a4186cc039c (patch)
treea30d6984d3a36158794be1d8c57c7bcd46530964 /src/test/java
parent9cbc19c49933411cdd7e57e7c5de9a04314a387c (diff)
Specify primary key for tables
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/ast/untyped/UntypedTableDefinitionNodeMatcher.java6
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserDatabaseSchemaDefinitionTests.java2
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserTableDefinitionTests.java2
3 files changed, 10 insertions, 0 deletions
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ast/untyped/UntypedTableDefinitionNodeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/ast/untyped/UntypedTableDefinitionNodeMatcher.java
index 8e4226c..6f8bdfc 100644
--- a/src/test/java/org/zwobble/hobgoblin/compiler/ast/untyped/UntypedTableDefinitionNodeMatcher.java
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/ast/untyped/UntypedTableDefinitionNodeMatcher.java
@@ -42,6 +42,12 @@ public final class UntypedTableDefinitionNodeMatcher implements org.zwobble.prec
return new org.zwobble.hobgoblin.compiler.ast.untyped.UntypedTableDefinitionNodeMatcher(submatchers);
}
+ public org.zwobble.hobgoblin.compiler.ast.untyped.UntypedTableDefinitionNodeMatcher withPrimaryKey(org.zwobble.precisely.Matcher<? super String> primaryKey) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.untyped.UntypedTableDefinitionNode>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("primaryKey", org.zwobble.hobgoblin.compiler.ast.untyped.UntypedTableDefinitionNode::primaryKey, (org.zwobble.precisely.Matcher) primaryKey));
+ return new org.zwobble.hobgoblin.compiler.ast.untyped.UntypedTableDefinitionNodeMatcher(submatchers);
+ }
+
public org.zwobble.hobgoblin.compiler.ast.untyped.UntypedTableDefinitionNodeMatcher withDocComment(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.DocComment> docComment) {
var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.untyped.UntypedTableDefinitionNode>>(this.submatchers);
submatchers.add(org.zwobble.precisely.Matchers.has("docComment", org.zwobble.hobgoblin.compiler.ast.untyped.UntypedTableDefinitionNode::docComment, (org.zwobble.precisely.Matcher) docComment));
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserDatabaseSchemaDefinitionTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserDatabaseSchemaDefinitionTests.java
index 5c41fa1..4a74324 100644
--- a/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserDatabaseSchemaDefinitionTests.java
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserDatabaseSchemaDefinitionTests.java
@@ -33,10 +33,12 @@ public class ParserDatabaseSchemaDefinitionTests {
databaseSchema BlogApp {
table posts {
row Post;
+ primaryKey id;
}
table author {
row Author;
+ primaryKey id;
}
}""";
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserTableDefinitionTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserTableDefinitionTests.java
index 889b30c..3c3b259 100644
--- a/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserTableDefinitionTests.java
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserTableDefinitionTests.java
@@ -14,6 +14,7 @@ public class ParserTableDefinitionTests {
var source = """
table posts {
row Post;
+ primaryKey id;
}""";
var node = parseString(
@@ -24,6 +25,7 @@ public class ParserTableDefinitionTests {
assertThat(node, isUntypedTableDefinitionNode()
.withName(equalTo("posts"))
.withRowType(isUntypedTypeLevelReferenceNode().withName(equalTo("Post")))
+ .withPrimaryKey(equalTo("id"))
);
}
}