Skip to content

[Bug]: Output columns incorrectly processed for MySql #1648

@ayush3797

Description

@ayush3797

Currently Output columns are incorrectly handled while generating SELECT query for MySql after update via UPSERT operation.
Relevant code snippet:
image
Link to file:

selections.Add($"{structure.Values[index]} AS {quotedColName}");

Where is the bug?
As we can observe that in the attached code snippet, we are processing the output columns one by one. The IF block for line 293 is hit when we find a column which is present in the structure.InsertColumns. We add such a column to the final selections and increment the index:

selections.Add($"{structure.Values[index]} AS {quotedColName}");
index++;

What have we assumed here?
We have assumed that the order of columns in structure.InsertColumns is same as structure.OutputColumns. Well that is certainly not true as output columns can have columns other that insertColumns and even if the columns are same, the order can differ. So, we cannot just reference structure.Values[index] on line 293 and increment the index on line 294.. We need to be sure that this output column, which is also an insert column, corresponds to this parameter name at structure.Values[index] (structure.Values essentially stores parameter names for each of the insert columns).

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingmysqlan issue thats specific to mysql

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions