-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/50 support merge statement (#53)
* #52: `MERGE` now supports `WHERE`
- Loading branch information
1 parent
e8a5413
commit e78d2bc
Showing
17 changed files
with
372 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/main/java/com/exasol/sql/dml/merge/MergeMethodDefinition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.exasol.sql.dml.merge; | ||
|
||
import com.exasol.sql.AbstractFragment; | ||
import com.exasol.sql.Fragment; | ||
import com.exasol.sql.dql.select.WhereClause; | ||
import com.exasol.sql.expression.BooleanExpression; | ||
|
||
/** | ||
* Abstract base class for merge method definitions like {@code WHEN MATCHED THEN UPDATE}. | ||
*/ | ||
public abstract class MergeMethodDefinition extends AbstractFragment { | ||
protected WhereClause where = null; | ||
|
||
/** | ||
* Create the abstract base for a merge method definition. | ||
* | ||
* @param root root {@code MERGE} statement | ||
*/ | ||
public MergeMethodDefinition(final Fragment root) { | ||
super(root); | ||
} | ||
|
||
/** | ||
* Add a {@code WHERE} clause {@code MERGE} definition. | ||
* | ||
* @param expression filter expression | ||
* @return parent {@code MERGE} statement | ||
*/ | ||
public Merge where(final BooleanExpression expression) { | ||
final Merge merge = (Merge) this.getRoot(); | ||
this.where = new WhereClause(merge, expression); | ||
return merge; | ||
} | ||
|
||
/** | ||
* Get the {@code WHERE} clause of the merge method definition. | ||
* | ||
* @return {@code WHERE} clause | ||
*/ | ||
public WhereClause getWhere() { | ||
return this.where; | ||
} | ||
|
||
/** | ||
* Check if the {@code WHERE} clause exists. | ||
* | ||
* @return {@code true} if the {@code WHERE} clause exists | ||
*/ | ||
public boolean hasWhere() { | ||
return this.where != null; | ||
} | ||
} |
Oops, something went wrong.