#1 2014-12-30 16:45:33

ubaltino
Member
From: Brasil
Registered: 2014-05-23
Posts: 24
Website

Possible Problem in function CreateAndFillPrepare Unit SynPlatformREST

For this function to work with a Field List, had to make the following change below:

From:

function TSQLModelInfo.SQLSelect(const FieldNames: string): string;
begin
  result := 'select '+FieldBitsToFieldNames(FieldNamesToFieldBits(
     FieldNames,false))+' from '+Name;
end;

To:

function TSQLModelInfo.SQLSelect(const FieldNames: string): string;
begin
  if ((FieldNames = '') or (FieldNames = '*')) then
    result := 'select '+FieldBitsToFieldNames(FieldNamesToFieldBits(
      FieldNames,false))+' from '+Name
  else
    result := 'select '+FieldNames+' from '+Name;
end;

You may have a more elegant way to solve this.


Ubaltino Faleiro
www.sistemainteligente.com
Brasil - Goiás - Goiânia

Offline

#2 2014-12-30 16:55:02

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: Possible Problem in function CreateAndFillPrepare Unit SynPlatformREST

What is wrong with the current implementation?
Its purpose is to normalize the field names so that the generated SQL would match the declared field order, to enhance caching abilities.

I do not find the mean of your modification.

Offline

#3 2014-12-30 17:42:49

ubaltino
Member
From: Brasil
Registered: 2014-05-23
Posts: 24
Website

Re: Possible Problem in function CreateAndFillPrepare Unit SynPlatformREST

Sorry, did not explain why my amendment.

Using SynCrossPlatformREST if I call the declaration:
SQL_Loja_Cadastro := TSQL_Loja_Cadastro.CreateAndFillPrepare(gServidores.ServidorBancoDados, 'ID, Nome_Fantasia, RAZAO_SOCIAL, CPF_CNPJ', 'id_usuario_proprietario = ' + IntToStr(ID_Usuario), []);

Should generate a select so the server
SELECT ID, Nome_Fantasia, RAZAO_SOCIAL, CPF_CNPJ FROM NAME_TABELA
Correct?

But this taking only the first field, select the result is wrong. Like This:
SELECT ID FROM NAME_TABELA

I hope it was clear now.


Ubaltino Faleiro
www.sistemainteligente.com
Brasil - Goiás - Goiânia

Offline

#4 2014-12-30 17:59:40

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: Possible Problem in function CreateAndFillPrepare Unit SynPlatformREST

Try without the spaces between the fields, e.g.  'ID,Nome_Fantasia,RAZAO_SOCIAL,CPF_CNPJ'

Offline

#5 2014-12-30 18:11:06

ubaltino
Member
From: Brasil
Registered: 2014-05-23
Posts: 24
Website

Re: Possible Problem in function CreateAndFillPrepare Unit SynPlatformREST

Resolved. Thank.

But maybe you should change your code so others do not go through the same problem.


Ubaltino Faleiro
www.sistemainteligente.com
Brasil - Goiás - Goiânia

Offline

#6 2014-12-30 18:49:55

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: Possible Problem in function CreateAndFillPrepare Unit SynPlatformREST

Indeed.

Should be fixed by http://synopse.info/fossil/info/93d421aa63

Thanks for the report!

Offline

Board footer

Powered by FluxBB