You are not logged in.
Pages: 1
Hi Ab,
is it possible to define a field as auto-increment within mORMot? Or should I exceute a custom SQL like "ALTER TABLE <fieldname> auto_increment" after a table was created?
Thank you!
Offline
There is no such feature built yet in the framework.
And I doubt there would be any soon.
IMHO such auto-increment fields should be part of the business logic, not handled of the storage layer.
If you trick at database level, you would not be able to switch from MySQL to another DB.
If you want an auto-incremented field, the TSQLRecord.ID would be one, available on all target databases.
Offline
...
If you want an auto-incremented field, the TSQLRecord.ID would be one, available on all target databases.
What dou you mean?
Maybe we don't understand each other ;-) I explain my use case:
In generel, I want to have a possibility the mORMot framework define TSQLRecord.ID as an auto-increment ID.
I have en external DB. There are many tables which have the auto-increment ID.
I define the class and let mORMot create the corresponding table:
TMyTable = class(TSQLRecord)
published
Field1: string;
Field2: string;
end;
...
fServer.CreateMissingTables();
...
The table "mytable" is created, but the ID field is not auto_increment. I know that not all database support this functionality.
Maybe I repeat myself, but would it make sense to have something like:
fServer.CreateMissingTables(0, [SetAutoIncrement4TSQLRecordID]);
Sorry for bothering you, maybe it's nonsense what I propose, but anyway ;-)
And thank you for your help!
Offline
Pages: 1