TAutoIncField not generated automatically with SQL Azure

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

TAutoIncField not generated automatically with SQL Azure

Post by ziclope » Fri 24 Feb 2017 11:11

Hello,

I noticed that AutoIncfields (identity) are created as TIntegerField,

I use direct mode

Regards

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

Re: TAutoIncField not generated automatically with SQL Azure

Post by ViktorV » Fri 24 Feb 2017 13:18

Yes, you are right and it is correct UniDAC behavior.
UniDAC when working with Azure fills in auto-incremental fields automatically on inserting a new record to a dataset, independently on whether they have the TIntegerField type or TAutoIncField.
You can define whether a field is auto-incremental in the following way:

Code: Select all

  if UniQuery.GetFieldDesc('YourField').IsAutoIncrement then
    // ...  Field is AutoIncrement

StefanDWC
Posts: 24
Joined: Mon 22 May 2017 08:42

Re: TAutoIncField not generated automatically with SQL Azure

Post by StefanDWC » Mon 22 May 2017 09:24

Hello, is there a way to implement an provider specific option wich allows to use TAutoIncField for all Identity columns?
Because, all common components (wich are based on TDataSet) expect that autoinc fields have this type.
That includes also DevExpress which i use since many years with other DB frameworks.

And now, it hangs only on a total uncommon behavior of the DB framework to which i want change.
(i use trial 7.0.1)

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: TAutoIncField not generated automatically with SQL Azure

Post by azyk » Tue 23 May 2017 08:59

We are investigating the possibility of returning the ftAutoInc field type for auto-increment fields and will inform you about the results.

StefanDWC
Posts: 24
Joined: Mon 22 May 2017 08:42

Re: TAutoIncField not generated automatically with SQL Azure

Post by StefanDWC » Tue 23 May 2017 11:22

Thanks for you reply!
I had a deeper look into that case. Azure generates the new value automatically while posting a new record. If you use the Microsoft SSMS for test on database level you can see Identity fields are not able to edit. Means they are managed from the database.

What was you concern to use TInteger instead of TAutoInc for identity fields? Maybe it help to understand why ViktorV called it as correct behavior for UniDAC.

Btw. i can't find any description / information in the Helpfile about the GetFieldDesc function and its result type.

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: TAutoIncField not generated automatically with SQL Azure

Post by azyk » Wed 24 May 2017 12:55

UniDAC provider for SQL Server returns for INT IDENTITY fields the TIntegerField class and set the TIntegerField.ReadOnly property to True. When calling the TUniQuery.Post method UniDAC requests the IDENTITY field value for the inserted record and returns this value to the TIntegerField instance. All the above corresponds to the behavior of auto-increment fields.

The GetFieldDesc method returns the TFieldDesc object which contains meta information about TUniQuery dataset field. As an argument this method can accept:
- the TField field instance
- a field name as a string value
- a field ordinal number in dataset as an integer value

In UniDAC the TFieldDesc class is developed for internal use, so its description is missing in the documentation.

StefanDWC
Posts: 24
Joined: Mon 22 May 2017 08:42

Re: TAutoIncField not generated automatically with SQL Azure

Post by StefanDWC » Wed 24 May 2017 14:17

Thanks for you explanation, Azyk.
In UniDAC the TFieldDesc class is developed for internal use, so its description is missing in the documentation.
Ok, that means we should use an undocumentet function for find out if a field is autoinc or not. That will work als long we know that we work with UniDac. But all our components which are work with TDataSet have no clue about that.

As far as i know means INT IDENTITY in every case autoinc. And TAutoInc field means an integer, read only, generated by the database. An TInteger field which is read only means calculated. So, still not editable for some reason.

I think, the DataType of an INT IDENTITY should be AutoInc (TAutoInc field class) and all should work fine.
If you think, that it will make a problem in some case, please tell me, will see if it helps to talk about ;-)

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: TAutoIncField not generated automatically with SQL Azure

Post by azyk » Mon 29 May 2017 11:46

The investigation of implementation possibility is still in progress. We will inform you about the results.

StefanDWC
Posts: 24
Joined: Mon 22 May 2017 08:42

Re: TAutoIncField not generated automatically with SQL Azure

Post by StefanDWC » Mon 29 May 2017 12:01

Thank you very much, Azyk.

Post Reply