Skip to content

remove unnecessary nullness checking in AbstractSqlAstTranslator#visitInsertStatementOnly() #10175

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1269,20 +1269,15 @@ protected void visitInsertStatementOnly(InsertSelectStatement statement) {
boolean firstPass = true;

final List<ColumnReference> targetColumnReferences = statement.getTargetColumns();
if ( targetColumnReferences == null ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

	@Override
	public List<ColumnReference> getTargetColumns() {
		return targetColumnReferences == null ? Collections.emptyList() : targetColumnReferences;
	}

as per the above logic, statement.getTargetColumns() is non-null.

On the other hand, checking emptiness seems unnecessary as well for either HQL or Criteria has guarded against such possibility (HQL's BNF grammar doesn't allow empty insert columns list; Criteria would have throws SemanticException).

renderImplicitTargetColumnSpec();
}
else {
for (ColumnReference targetColumnReference : targetColumnReferences) {
if (firstPass) {
firstPass = false;
}
else {
appendSql( COMMA_SEPARATOR_CHAR );
}

appendSql( targetColumnReference.getColumnExpression() );
for (ColumnReference targetColumnReference : targetColumnReferences) {
if (firstPass) {
firstPass = false;
}
else {
appendSql( COMMA_SEPARATOR_CHAR );
}

appendSql( targetColumnReference.getColumnExpression() );
}

appendSql( ") " );
Expand Down Expand Up @@ -1637,9 +1632,6 @@ protected void renderMergeUpdateClause(List<Assignment> assignments, Predicate w
renderSetClause( assignments );
}

private void renderImplicitTargetColumnSpec() {
}

protected void visitValuesList(List<Values> valuesList) {
visitValuesListStandard( valuesList );
}
Expand Down
Loading