diff options
Diffstat (limited to 'src/main')
3 files changed, 42 insertions, 1 deletions
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriter.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriter.java index 04c7869..4e0b71b 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriter.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriter.java @@ -187,6 +187,10 @@ public class SqlWriter { this.writeIntLiteral(intLiteral); } + case SqlParamRef paramRef -> { + this.writeParamRef(paramRef); + } + case SqlRef ref -> { this.writeRef(ref); } @@ -219,6 +223,11 @@ public class SqlWriter { this.writer.write(Long.toString(intLiteral.value())); } + private void writeParamRef(SqlParamRef paramRef) throws IOException { + this.writer.write("?"); + this.writer.write(Integer.toString(paramRef.number())); + } + private void writeRef(SqlRef ref) throws IOException { this.writeIdentifier(ref.name()); } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlExpression.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlExpression.java index 10b4e93..6075ebc 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlExpression.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlExpression.java @@ -5,7 +5,7 @@ package org.zwobble.hobgoblin.compiler.output.lang.sql.ast; // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression imports // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression imports -public sealed interface SqlExpression permits org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlBinaryOperation, org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlColumnReference, org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIntLiteral, org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRef { +public sealed interface SqlExpression permits org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlBinaryOperation, org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlColumnReference, org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIntLiteral, org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef, org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRef { public interface Builder { public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression build(); diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlParamRef.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlParamRef.java new file mode 100644 index 0000000..f2203dd --- /dev/null +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlParamRef.java @@ -0,0 +1,32 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.sql.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef imports + +public record SqlParamRef( + int number +) implements org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression { + public static org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef.Builder arbitrary() { + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef.Builder(0); + } + + public record Builder( + int number + ) implements org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression.Builder { + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef build() { + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef(number); + } + + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef.Builder withNumber(int number) { + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef.Builder(number); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef.Builder body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef.Builder body + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef body +} |
