-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
support opengauss "on duplicate key update nothing" grammar #2303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
manticore-projects
merged 4 commits into
JSQLParser:master
from
zhangconan:fix/duplicate-nothing
Aug 28, 2025
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6429742
support opengauss "on duplicate key nothing" grammar
b65b51c
use import single classes instead of wildcard imports in Insert class.
48f905e
use import single classes instead of wildcard imports in Insert class.
7c66eb1
use './gradlew :spotlessApply' adjust code format.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
117 changes: 117 additions & 0 deletions
117
src/main/java/net/sf/jsqlparser/statement/insert/InsertDuplicateAction.java
This file contains hidden or 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,117 @@ | ||
/*- | ||
* #%L | ||
* JSQLParser library | ||
* %% | ||
* Copyright (C) 2004 - 2025 JSQLParser | ||
* %% | ||
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0 | ||
* #L% | ||
*/ | ||
package net.sf.jsqlparser.statement.insert; | ||
|
||
import net.sf.jsqlparser.expression.Expression; | ||
import net.sf.jsqlparser.schema.Column; | ||
import net.sf.jsqlparser.statement.update.UpdateSet; | ||
|
||
import java.io.Serializable; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
/** | ||
* on duplicate key is one of: | ||
* | ||
* ON DUPLICATE KEY UPDATE NOTHING ON DUPLICATE KEY UPDATE { column_name = { expression | DEFAULT } | ( column_name [, ...] ) = [ ROW ] ( { expression | DEFAULT | ||
* } [, ...] ) | ( column_name [, ...] ) = ( sub-SELECT ) } [, ...] [ WHERE condition ] | ||
* | ||
* @author zhangconan | ||
*/ | ||
public class InsertDuplicateAction implements Serializable { | ||
|
||
ConflictActionType conflictActionType; | ||
Expression whereExpression; | ||
private List<UpdateSet> updateSets; | ||
|
||
public InsertDuplicateAction(ConflictActionType conflictActionType) { | ||
this.conflictActionType = Objects.requireNonNull(conflictActionType, "The Conflict Action Type is mandatory and must not be Null."); | ||
} | ||
|
||
public List<UpdateSet> getUpdateSets() { | ||
return updateSets; | ||
} | ||
|
||
public void setUpdateSets(List<UpdateSet> updateSets) { | ||
this.updateSets = updateSets; | ||
} | ||
|
||
public InsertDuplicateAction withUpdateSets(List<UpdateSet> updateSets) { | ||
this.setUpdateSets(updateSets); | ||
return this; | ||
} | ||
|
||
public ConflictActionType getConflictActionType() { | ||
return conflictActionType; | ||
} | ||
|
||
public void setConflictActionType(ConflictActionType conflictActionType) { | ||
this.conflictActionType = Objects.requireNonNull(conflictActionType, "The Conflict Action Type is mandatory and must not be Null."); | ||
} | ||
|
||
public InsertDuplicateAction withConflictActionType(ConflictActionType conflictActionType) { | ||
setConflictActionType(conflictActionType); | ||
return this; | ||
} | ||
|
||
public InsertDuplicateAction addUpdateSet(Column column, Expression expression) { | ||
return this.addUpdateSet(new UpdateSet()); | ||
} | ||
|
||
public InsertDuplicateAction addUpdateSet(UpdateSet updateSet) { | ||
if (updateSets == null) { | ||
updateSets = new ArrayList<>(); | ||
} | ||
this.updateSets.add(updateSet); | ||
return this; | ||
} | ||
|
||
public InsertDuplicateAction withUpdateSets(Collection<UpdateSet> updateSets) { | ||
this.setUpdateSets(new ArrayList<>(updateSets)); | ||
return this; | ||
} | ||
|
||
public Expression getWhereExpression() { | ||
return whereExpression; | ||
} | ||
|
||
public void setWhereExpression(Expression whereExpression) { | ||
this.whereExpression = whereExpression; | ||
} | ||
|
||
public InsertDuplicateAction withWhereExpression(Expression whereExpression) { | ||
setWhereExpression(whereExpression); | ||
return this; | ||
} | ||
|
||
@SuppressWarnings("PMD.SwitchStmtsShouldHaveDefault") | ||
public StringBuilder appendTo(StringBuilder builder) { | ||
switch (conflictActionType) { | ||
case NOTHING: | ||
builder.append(" NOTHING "); | ||
break; | ||
default: | ||
UpdateSet.appendUpdateSetsTo(builder, updateSets); | ||
|
||
if (whereExpression != null) { | ||
builder.append(" WHERE ").append(whereExpression); | ||
} | ||
break; | ||
} | ||
return builder; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return appendTo(new StringBuilder()).toString(); | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid wildcard imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I will adjust the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have adjusted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':publishMavenJavaPublicationToOssrhRepository'.
Failed to publish publication 'mavenJava' to repository 'ossrh'
Could not PUT 'https://central.sonatype.com/repository/maven-snapshots/com/github/jsqlparser/jsqlparser/5.4-SNAPSHOT/jsqlparser-5.4-20250828.114640-16.jar'. Received status code 401 from server: Unauthorized
There seems to be a problem with the username or password of the Maven repository