Problems with TField.Origin property

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
ziclope
Posts: 27
Joined: Fri 24 Feb 2006 11:34

Problems with TField.Origin property

Post by ziclope » Fri 24 Mar 2006 13:21

Hello,

I have a SQL with various joins. The problem is when 2 tables have fields with the same name. This property doesn´t show the correct name. Example for Field Status:

When Open the query all fields are filled

Field.Origin = TableA.Status
Field.Origin = TableB.Status_1

but Status_1 doesn´t exists

Regards

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Fri 24 Mar 2006 14:25

Try specifying field names manually. For example:

Code: Select all

SELECT Table1.Field1 as T1F1, Table2.Field1 as T2F1 ...
This helps to avoid collisions with field names.

ziclope
Posts: 27
Joined: Fri 24 Feb 2006 11:34

Post by ziclope » Fri 24 Mar 2006 15:08

The problem is that I need The composed field in origin
for recreate the SQL query.

for example:

SELECT * FROM articulos, articulos_details where
articulos.Field = 1 and articulos_details.Field = 1

The problem is in generated fields:

articulos.Field
articulos_details.Field_1 <- This is the problem !!!

Do you understand me ?

GEswin
Posts: 186
Joined: Wed 03 Nov 2004 16:57
Location: Spain
Contact:

Post by GEswin » Fri 24 Mar 2006 22:59

In this case you need to write your own SQLUpdate sentence, or specify the fields in the select

Code: Select all

SELECT a.field as Field,b.field as Field2, ... FROM articulos a, articulos_details b .....

ziclope
Posts: 27
Joined: Fri 24 Feb 2006 11:34

Post by ziclope » Sat 25 Mar 2006 12:38

You don´t understand me

I use Origin for create an automatic complex query.
I don´t need a SQLUpdate...

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Mon 27 Mar 2006 08:57

We will think about changing this behavior in next MyDAC version.

ziclope
Posts: 27
Joined: Fri 24 Feb 2006 11:34

Post by ziclope » Mon 27 Mar 2006 10:17

this behavior ? for do ?
Exists any date for new release of MyDAC ?

Changing to my question...
How could I know all real fields for queries with joins ?
I need decode all field in result. For example:

Field1 = Table1.Name,
Field2 = Table2.Name,
Field3 = Table1.Date,
....

Regards

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Tue 28 Mar 2006 08:38

> this behavior ? for do ?

I mean method to set values for Fields.Origin. Changing this method can cause problems for other MyDAC users who use old behavior.

> Exists any date for new release of MyDAC ?

We can't specify any terms.

> How could I know all real fields for queries with joins ?

As temporary solution you can try to remove '_' from Origin.

ziclope
Posts: 27
Joined: Fri 24 Feb 2006 11:34

Post by ziclope » Fri 01 Sep 2006 06:49

Any changes with TField.Origin behavior ?

With ADOExpress you fill in manually this property. Is the best solution because in complex query.

Regards

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Fri 01 Sep 2006 08:40

In the next version of MyDAC we will add a new option that will enable/disable automatic generating of fields origin. And the behavior itself will be changed as well. For example, both Table1 and Table2 have field named `uid`:

Code: Select all

Old generated origins:      New generated origins:
    Table1.uid                  Table1.uid
    Table2.uid_1                Table2.uid

a.alekizoglou
Posts: 32
Joined: Fri 22 Sep 2006 08:32

Any news on this?

Post by a.alekizoglou » Tue 03 Oct 2006 14:54

I have the same problem and waiting for the new build. I saw there is a new version out but did not find any solution to this problem.

Ikar, in a previous post you said as a temporary solution remove _(name). What is that, how can we remove something from .Origin since this is a readonly property?

Regards,

Athanasios Alekizoglou

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Wed 04 Oct 2006 09:00

The option mentioned in my previous post will be added in the next version of MyDAC (MyDAC 5) but not in the next build. That's why you have not found solution in the last build of MyDAC. As a rule we do not change public interface in builds, all changes in the interface are applied to new version of MyDAC.

> Ikar, in a previous post you said as a temporary solution remove _(name). What is
> that, how can we remove something from .Origin since this is a readonly property?
You can assign value of Origin property using for example following code:

Code: Select all

  MyQuery.Fields[0].Origin := 'correct_field_origin';

Post Reply