I’m changing the uniDAC dad driver to change the names of the table fields in pascalcase. I’m connet to oracle DB and all filed names are in upper case. I changed the method Oracle_DoGetTableFields of the unit uDAOracleInterfaces. I changed this:
original:
While not Query.Eof do begin
fld := Fields.Add;
fld.Name:=Query.Fields[0].AsString;
ldt:=OracleTypeToDADataType.....
with this:
While not Query.Eof do begin
fld := Fields.Add;
fld.Name:=PascalCaseString(Query.Fields[0].AsString); //Query.Fields[0].AsString;
fld.TableField := Query.Fields[0].AsString;
fld.SQLOrigin := Query.Fields[0].AsString;
The function PascalCaseString return a new string in pascal case format and remove the undescore char.
The problem is in the DASchemaModeler. Despite having set the TableField and SQLOrigin properties these are not read correctly. It seems that DASchemaModeler always takes the field name as reference for these settings.
Is it a problem of the DASchemeModeler? I tried to check in the code but the change I made seems the only possible one.
I’m creating a new application on a database that I don’t handle and I heavily use the strongly-typed access unit.
It would be an interesting feature to be able to integrate the management of the name of the field directly into DASchemaModeler but at the moment since there is no solution I have to automatically find the way to manage the name case without having to do it manually for all the datasets … which are really many.
many thanks for you answer. Your suggestion is not praticable for me because in many case I use AutoSQL option and not customize the SQL. In many case I use a dedicated view in AutoSQL and customize only the insert/update and delete statment.
So the only solution I see is to modify low-level APIs.
you can edit schema and change all mapping.TableField to upper case at starting your server.
Why you can’t just change field names then?
mapping will be looks like
Field1 | FIELD1 | FIELD1
it works with AutoSQL mode too
at starting server (or service), you can update service schema like:
for i:=0 to DASchema1.Datasets.Count -1 do
for j :=0 to DASchema1.Datasets[i].Statements.Count -1 do
for k := 0 to DASchema1.Datasets[i].Statements[j].ColumnMappings.Count -1 do
DASchema1.Datasets[i].Statements[j].ColumnMappings[k].TableField :=
UpperCase(DASchema1.Datasets[i].Statements[j].ColumnMappings[k].TableField);
Why you can’t just change field names then?
mapping will be looks like
Yes, but in this case I must made this manually. I need to menaged many datasets (about 1000).
I would like an automatic way that is managed inside of the DASchemaModeler.
at starting server (or service), you can update service schema like:
The problem is not only the case of the names but the result name of the field name is different of the real field name. For example
you can create a simple Delphi program that will modify Field and mapping.DatasetField in the same way as my code above.
so it won’t be a problem.
for processed tables, you can add a custom attribute so table won’t be processed twice.
just launch it after updating schema or update Delphi IDE package so your utility will be launched automatically after updating schema.
so from what I understand the only way is to modify the dfm afterwards (I use the schema internally in the DFM and not external).
I don’t understand why this cannot be managed directly by the DAD driver inasmuch internally use a TDAField object that supports the TableField and SQLAlias properties.
just launch it after updating schema or update Delphi IDE package so your utility will be launched automatically after updating schema.
not yet.
schema from .dfm is written to .daSchema and this .daSchema is passed to DASM, later .daSchema is read again into .dfm
check uDADataAbstractServerEditors.pas code:
procedure TDASchemaEditor.ExecuteVerb(Index: Integer);
..
case Index of
COMMAND_INDEX_EDIT: begin
...
try
lf := CreatePleaseWaitForm('Running the Schema Modeler...');
try
lf.Show();
ExecuteAndWait(GetSchemaModelerPath, '/ns /platform:Delphi /projectname:"'+GetComponent().Name+'" /autosave /schemafile:"'+sfname+'"');
//<<< add here call of your utility and pass `sfname` to it
lf.Hide();
finally
lf.Free();
end;