Skip to content

Commit

Permalink
Updates ConflictTargetConstraint to use an IdentifierChain
Browse files Browse the repository at this point in the history
  • Loading branch information
johnedquinn committed Dec 6, 2024
1 parent 3d822d0 commit 51f4ad1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 16 deletions.
8 changes: 4 additions & 4 deletions partiql-ast/api/partiql-ast.api
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public final class org/partiql/ast/Ast {
public static final fun columnConstraintNullable (Lorg/partiql/ast/IdentifierChain;Z)Lorg/partiql/ast/ddl/AttributeConstraint$Null;
public static final fun columnConstraintUnique (Lorg/partiql/ast/IdentifierChain;Z)Lorg/partiql/ast/ddl/AttributeConstraint$Unique;
public static final fun columnDefinition (Lorg/partiql/ast/Identifier;Lorg/partiql/ast/DataType;ZLjava/util/List;Ljava/lang/String;)Lorg/partiql/ast/ddl/ColumnDefinition;
public static final fun conflictTargetConstraint (Lorg/partiql/ast/Identifier;)Lorg/partiql/ast/dml/ConflictTarget$Constraint;
public static final fun conflictTargetConstraint (Lorg/partiql/ast/IdentifierChain;)Lorg/partiql/ast/dml/ConflictTarget$Constraint;
public static final fun conflictTargetIndex (Ljava/util/List;)Lorg/partiql/ast/dml/ConflictTarget$Index;
public static final fun createTable (Lorg/partiql/ast/IdentifierChain;Ljava/util/List;Ljava/util/List;Lorg/partiql/ast/ddl/PartitionBy;Ljava/util/List;)Lorg/partiql/ast/ddl/CreateTable;
public static final fun delete (Lorg/partiql/ast/IdentifierChain;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/dml/Delete;
Expand Down Expand Up @@ -1538,8 +1538,8 @@ public abstract class org/partiql/ast/dml/ConflictTarget : org/partiql/ast/AstNo
}

public final class org/partiql/ast/dml/ConflictTarget$Constraint : org/partiql/ast/dml/ConflictTarget {
public final field constraintName Lorg/partiql/ast/Identifier;
public fun <init> (Lorg/partiql/ast/Identifier;)V
public final field constraintName Lorg/partiql/ast/IdentifierChain;
public fun <init> (Lorg/partiql/ast/IdentifierChain;)V
public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object;
public static fun builder ()Lorg/partiql/ast/dml/ConflictTarget$Constraint$Builder;
public fun children ()Ljava/util/Collection;
Expand All @@ -1549,7 +1549,7 @@ public final class org/partiql/ast/dml/ConflictTarget$Constraint : org/partiql/a

public class org/partiql/ast/dml/ConflictTarget$Constraint$Builder {
public fun build ()Lorg/partiql/ast/dml/ConflictTarget$Constraint;
public fun constraintName (Lorg/partiql/ast/Identifier;)Lorg/partiql/ast/dml/ConflictTarget$Constraint$Builder;
public fun constraintName (Lorg/partiql/ast/IdentifierChain;)Lorg/partiql/ast/dml/ConflictTarget$Constraint$Builder;
public fun toString ()Ljava/lang/String;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.partiql.ast.AstNode;
import org.partiql.ast.AstVisitor;
import org.partiql.ast.Identifier;
import org.partiql.ast.IdentifierChain;

import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -66,13 +67,13 @@ public static final class Constraint extends ConflictTarget {
*/
// TODO: Should this be a qualified identifier?
@NotNull
public final Identifier constraintName;
public final IdentifierChain constraintName;

/**
* TODO
* @param constraintName TODO
*/
public Constraint(@NotNull Identifier constraintName) {
public Constraint(@NotNull IdentifierChain constraintName) {
this.constraintName = constraintName;
}

Expand Down
2 changes: 1 addition & 1 deletion partiql-ast/src/main/kotlin/org/partiql/ast/Ast.kt
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ public object Ast {
}

@JvmStatic
public fun conflictTargetConstraint(constraint: Identifier): ConflictTarget.Constraint {
public fun conflictTargetConstraint(constraint: IdentifierChain): ConflictTarget.Constraint {
return ConflictTarget.Constraint(constraint)
}

Expand Down
2 changes: 1 addition & 1 deletion partiql-ast/src/main/kotlin/org/partiql/ast/AstRewriter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ public abstract class AstRewriter<C> : AstVisitor<AstNode, C>() {
}

override fun visitConflictTargetConstraint(node: ConflictTarget.Constraint, ctx: C): AstNode {
val constraint = visitIdentifier(node.constraintName, ctx) as Identifier
val constraint = visitIdentifierChain(node.constraintName, ctx) as IdentifierChain
if (constraint !== node.constraintName) {
return ConflictTarget.Constraint(constraint)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -763,14 +763,7 @@ internal class PartiQLParserDefault : PartiQLParser {

override fun visitConflictTargetConstraint(ctx: GeneratedParser.ConflictTargetConstraintContext) = translate(ctx) {
val constraint = visitQualifiedName(ctx.constraintName().qualifiedName())
// TODO: Should constraint have a single name?
var last = constraint
var next = last.next
while (next != null) {
last = next
next = last.next
}
conflictTargetConstraint(last.root)
conflictTargetConstraint(constraint)
}

override fun visitConflictAction(ctx: GeneratedParser.ConflictActionContext): ConflictAction = translate(ctx) {
Expand Down

0 comments on commit 51f4ad1

Please sign in to comment.