Page 1 of 1

TUniUpdateSQL: Bug or feature?

Posted: Tue 21 Jan 2020 07:30
by LukasK
Hello,

since the update there are problems with the order of column names in update statements with the class TUniUpdateSQL. If several columns with the same name are selected from different tables in the query, also using aliases. If Modify SQL is used, the first column is always used for the parameters. Even if the alias is completely different.

Example:

[<TUniUpdateSQL>.ModifySQL]

Code: Select all

update TABLE1 T1
set T1 = :COLUMN1,
where T1.PRIMARYKEY1 = :PRIMARYKEY1 and
      T1.PRIMARYKEY2 = :PRIMARYKEY2   

[<TUniQuery>.SQL.Text]

Code: Select all

select T2.COLUMN1 as T2_COLUMN1, T1.COLUMN1, T1.PRIMARYKEY1, T1.PRIMARYKEY2
from TABLE1 T1
left outer join TABLE2 T2 on T2.PRIMARYKEY1 = T1.PRIMARYKEY1 and
      T2.PRIMARYKEY2 = 1 

SourceCode

Code: Select all

<TUniQuery>.CachedUpdates := True;
<TUniUpdateSQL>.DataSet := <TUniQuery>;
....
<TUniQuery>.Edit;
<TUniQuery>.FieldByName('Column1').AsInteger := 100;
<TUniQuery>.Post;
<TUniQuery>.ApplyUpdates;
<TUniUpdateSQL>.Apply(ukModify);
In this case, T2.COLUMN1 as T2_COLUMN1 is used as a parameter for the ModifySQL and not T1.COLUMN1.

Because the <TUniQuery>.FieldByName('Column1') was set, I would have expected that T1.COLUMN1 would be used.
For T2.COLUMN1 as T2_COLUMN1 the value from <TUniQuery>.FieldByName('T2_COLUMN1') should be used accordingly.
In version "7.4.12" the behaviour was still correct in my opinion. But at least since version "8.1.2" the behaviour is as described.

Is this a bug or are there possibly new properties to control this?

Re: TUniUpdateSQL: Bug or feature?

Posted: Wed 22 Jan 2020 12:41
by ViktorV
Please specify the DBMS (and its version) you are working with.

Re: TUniUpdateSQL: Bug or feature?

Posted: Wed 22 Jan 2020 13:04
by LukasK
Firebird - 3.0.4.33054

Re: TUniUpdateSQL: Bug or feature?

Posted: Wed 22 Jan 2020 13:21
by ViktorV
For a quicker and more complete answer, please create and send us via the contact forum on our website: https://devart.com/company/contactform.html a small example small sample demonstrating that behavior, including scripts for creating and populating database objects.