Underscores appearing in Table and Field Names

I have tables in my DB called control, control2 and control3.

I create the Aurelis objects and put them in the entities.pas unit.

When I use the following URL  http://localhost:2002/nethd/control it lists the rows in the table OK.

But if try it with control2 (or control3) I get told that table 'control_2' does not exist.

Similarly any table with a number at the end of a field gives the same type or error. e.g. field2 - xdata REST server says 'field_2' does not exist.

It did this also for uppercase letters in names, but I adjusted the code to just use lower case and that worked around it.

Somewhere something is processing some rules to do with uppercase and numbers in names....

This is with ADO and MSSQL server.

I suppose you are using the automapping features? That's the behavior of automapping, if it doesn't fit, you can always explicitly define the table (or column name), in this specific case, just add this attribute in your class declaration:



That fixed it.  For both table name and field names.

I can't see any reference to this default behaviour of automapping in the help file though. 

It does it for field names too.  Any numeric character anywhere in either a table name or a field name is changed to be prefixed by an underscore.

For the field names I had to put the [column] line in two places in the entities.pas file.

Here is an example of what I did for the DB table 'control2' with a field name called 'rsagenonslaitemcode2'.

  [Id('Frseq', TIdGenerator.None)]

  Tcontrol2 = class
    Frseq: integer;
    Frsagenonslaitemcode2: string;


    property rseq: integer read Frseq write Frseq;
    property rsagenonslaitemcode2: string read Frsagenonslaitemcode2 write Frsagenonslaitemcode2;

Still have a problem with these fields with numerics in their names.

The use of the 'column' word fixes the listing out of data.

But when I try and do a POST of a new row, I get this error message:

"Parameter object is improperly defined. Inconsistent or incomplete information was provided".

If I take out the fields with the numeric field names the POST works OK.

Maybe I need to say more about the column.

Is the database field that contains numeric values? Maybe you should enclose the field name in Column attribute using double quotes or brackets (for MS SQL Server):