TUniUpdateSQL: Bug or feature?

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
LukasK
Posts: 2
Joined: Tue 21 Jan 2020 06:51

TUniUpdateSQL: Bug or feature?

Post by LukasK » Tue 21 Jan 2020 07:30

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?

ViktorV
Devart Team
Posts: 2867
Joined: Wed 30 Jul 2014 07:16

Re: TUniUpdateSQL: Bug or feature?

Post by ViktorV » Wed 22 Jan 2020 12:41

Please specify the DBMS (and its version) you are working with.

LukasK
Posts: 2
Joined: Tue 21 Jan 2020 06:51

Re: TUniUpdateSQL: Bug or feature?

Post by LukasK » Wed 22 Jan 2020 13:04

Firebird - 3.0.4.33054

ViktorV
Devart Team
Posts: 2867
Joined: Wed 30 Jul 2014 07:16

Re: TUniUpdateSQL: Bug or feature?

Post by ViktorV » Wed 22 Jan 2020 13:21

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.

Post Reply