fkInternalCalc and RefreshOptions problem

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
rrsoftproj
Posts: 1
Joined: Mon 02 Mar 2020 14:36

fkInternalCalc and RefreshOptions problem

Post by rrsoftproj » Tue 03 Mar 2020 08:03

Hello,

I'm trying to upgrade from MyDAC for Delphi/C++ Builder (2006). From 7.6.11 to 10.1.2 (trial currently). Everything seems to work, except fields calculated on MySQL side like: count(*), subqueries fields etc.
Some time ago (migrating from 4.x to 7.x) the sollution was to set fields as fkInternalCalc and ReadOnly, and it worked like a charm.
Now I cannot enter dataset edit mode when - for example - RefreshOptions.roBeforeEdit is set to true. Looking at SQL monitor output, the query passed to DB is a SELECT with all the fields in dataset - event the fkInternalCalc ones.
So for example a simple query, counting positions for all documents:

Code: Select all

SELECT documents.id, count(*) AS poscount
     FROM documents, positions WHERE documents.key=posistions.master_key
     GROUP BY documents.id
When roBeforeEdit is set makes a query before edit:

Code: Select all

SELECT id AS _1, poscount AS _2 FROM documents WHERE id='exampledocument'
This of course fails as the field "poscount" does NOT exists in database.

It does not matter wheter I set field origins, updating table, key fields, provider flags, hidden, readolny, required etc.

The solution is to append

Code: Select all

WHERE documents.id = :ID
somewhere in the code. However the queries are quite complex, build real-time, and counted in hundreds of controls.

So - the final question. Is this a bug, or is there some kind of compatiblity flag, to regain fkInternalCalc behaviour from version 7.x, without the need of creating SQLRefresh and changing half of the project?

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

Re: fkInternalCalc and RefreshOptions problem

Post by ViktorV » Tue 03 Mar 2020 12:21

In order to get a detailed answer, please compose a small sample demonstrating the specified behavior and send it to us using the contact form https://devart.com/company/contactform.html including scripts for creating and filling database objects.

Post Reply