@@ -1159,8 +1159,9 @@ protected void visitSetAssignment(Assignment assignment) {
1159
1159
}
1160
1160
final List <ColumnReference > columnReferences = assignable .getColumnReferences ();
1161
1161
final Expression assignedValue = assignment .getAssignedValue ();
1162
+ final boolean affectMutlipleTables = affectedTableNames .size () > 1 ;
1162
1163
if ( columnReferences .size () == 1 ) {
1163
- columnReferences .get ( 0 ). appendColumnForWrite ( this , null );
1164
+ appendColumn ( columnReferences .get ( 0 ) );
1164
1165
appendSql ( '=' );
1165
1166
final SqlTuple sqlTuple = getSqlTuple ( assignedValue );
1166
1167
if ( sqlTuple != null ) {
@@ -1175,7 +1176,7 @@ else if ( assignedValue instanceof SelectStatement ) {
1175
1176
char separator = OPEN_PARENTHESIS ;
1176
1177
for ( ColumnReference columnReference : columnReferences ) {
1177
1178
appendSql ( separator );
1178
- columnReference . appendColumnForWrite ( this , null );
1179
+ appendColumn ( columnReference );
1179
1180
separator = COMMA_SEPARATOR_CHAR ;
1180
1181
}
1181
1182
appendSql ( ")=" );
@@ -1184,7 +1185,7 @@ else if ( assignedValue instanceof SelectStatement ) {
1184
1185
else {
1185
1186
assert assignedValue instanceof SqlTupleContainer ;
1186
1187
final List <? extends Expression > expressions = ( (SqlTupleContainer ) assignedValue ).getSqlTuple ().getExpressions ();
1187
- columnReferences .get ( 0 ). appendColumnForWrite ( this , null );
1188
+ appendColumn ( columnReferences .get ( 0 ) );
1188
1189
appendSql ( '=' );
1189
1190
expressions .get ( 0 ).accept ( this );
1190
1191
for ( int i = 1 ; i < columnReferences .size (); i ++ ) {
@@ -1196,6 +1197,15 @@ else if ( assignedValue instanceof SelectStatement ) {
1196
1197
}
1197
1198
}
1198
1199
1200
+ private void appendColumn (ColumnReference column ) {
1201
+ if ( affectedTableNames .size () > 1 ) {
1202
+ column .appendColumnForWrite ( this );
1203
+ }
1204
+ else {
1205
+ column .appendColumnForWrite ( this , null );
1206
+ }
1207
+ }
1208
+
1199
1209
protected void visitSetAssignmentEmulateJoin (Assignment assignment , UpdateStatement statement ) {
1200
1210
final Assignable assignable = assignment .getAssignable ();
1201
1211
if ( assignable instanceof SqmPathInterpretation <?> sqmPathInterpretation ) {
0 commit comments