#1 2014-05-20 16:55:51

fabioquestor
Member
From: Chapecó, SC, Brasil
Registered: 2014-05-19
Posts: 13
Website

Table not Id: integer

Hello

I have a legacy base, with over 1000 tables , most with multiple primary key without ID , how can I do to use ORM ?
The only way is to convert the tables to have id?
example :

type
  / / / STATE Table
  / / - Type definition auto-generated by SynDBExplorer at 1:18 20/05/2014 13:44:50
  / / From STATE
  / / - Note que the ORM will add one missing ID field via:
  / / $ ALTER TABLE ADD STATE ID INTEGER
  TSQLSTATE = class ( TSQLRecord )
  protected
    fSTATEABBREVIATION : RawUTF8 ;
    fSTATENAME : RawUTF8 ;
    fSTATEBRAZIL : Boolean ;
    fCOUNTRYCODE : Int64 ;
  published
    / / / Match STATE.SIGLA STATE [ CHAR 2 0 0 ] * primary key
    property STATEABBREVIATION: RawUTF8 index 2 read fSTATEABBREVIATION write fSTATEABBREVIATION;
    / / / Match STATE.STATENAME [ VARCHAR 30 0 0 ]
    property STATENAME: RawUTF8 index 30 read fSTATENAME write fSTATENAME;
    / / / Match STATE.STATEBRAZIL [ CHAR 1 0 0 ]
    property STATEBRAZIL: Boolean index 1 read fSTATEBRAZIL write fSTATEBRAZIL;
    / / / Match STATE.COUNTRYCODE [ SMALLINT ] *
    property COUNTRYCODE: Int64 read fCOUNTRYCODE write fCOUNTRYCODE;
  end ;

Got any tips ?

Offline

#2 2014-05-20 18:23:40

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

Re: Table not Id: integer

You can change the name of the ID field, via mapping, if there is an integer primary key.

But the primary key should be an integer, otherwise the ORM won't work...

There is no simple workaround yet...

Offline

#3 2014-05-20 19:54:49

fabioquestor
Member
From: Chapecó, SC, Brasil
Registered: 2014-05-19
Posts: 13
Website

Re: Table not Id: integer

thank you
I will be working

I've searched but have not found a ready system using mORMot, have to get me some?

A real life example.

Except mORMot\SQLite3\Samples\MainDemo\SynFile.dpr

PS I'm working on a mORMot DBExpress to drive, so I will send you complete.

Last edited by fabioquestor (2014-05-20 19:56:42)

Offline

#4 2014-05-20 21:08:37

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

Re: Table not Id: integer

All I know are proprietary software.

But used on production in area as diverse as massive client/server or biological automated devices..
:-)

Offline

#5 2014-05-21 15:27:54

ComingNine
Member
Registered: 2010-07-29
Posts: 294

Re: Table not Id: integer

ab wrote:

But the primary key should be an integer, otherwise the ORM won't work...

There is no simple workaround yet...

Could you help to elaborate the reason ? roll

I would think that multiple-string-field primary key is rather common ?

Last edited by ComingNine (2014-05-21 15:28:42)

Offline

#6 2014-05-21 18:43:10

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

Re: Table not Id: integer

Offline

#7 2014-05-21 20:32:33

ComingNine
Member
Registered: 2010-07-29
Posts: 294

Re: Table not Id: integer

Very good reasoning ! roll

Offline

Board footer

Powered by FluxBB