You are not logged in.
Pages: 1
I have a fairly new project in the past month using mORMot 1.18.
I tried to migrated it to mORMot 2, today, following @ab advice.
The code update was pretty smooth, and the code built fine.
Then the exception showed up, when calling TRestServerDB.CreateMissingTables: Exception class EZSQLException with message 'SQL Error: ERROR: relation "some_table" already exists
ERROR 42P07relation "some_table" already exists
Shouldn't CreateMissingTables only try to create tables when "missing"? But it seemed it tried to create existing tables?
What is the catch here?
Last edited by wxinix (2021-05-15 20:55:07)
Offline
I use Postgresql connection class. It seems that mormot.db.sql.zeos, the following method doesn't work properly?
procedure TSqlDBZeosConnectionProperties.GetFields(const aTableName: RawUtf8;
out Fields: TSqlDBColumnDefineDynArray);
Line 696
res := meta.GetColumns('', sSchema,
meta.AddEscapeCharToWildcards(sTableName), '');
always returns EMPTY, thus the returned
out Fields: TSqlDBColumnDefineDynArray
is always empty. On the other hand, however, from the backend PostgreSQL server log, I can see that the server is queried with correctly generated SQL, which indeed returned the list of fields.
Because returned Fields is always empty, CreateMissingTables will always try to recreate existing tables because of the empty Fields returned.
Is this a bug of mORMot2, or I am doing something wrong somewhere?
Last edited by wxinix (2021-05-16 12:20:37)
Offline
OK.
I believe there is a bug of mORMot2
mormot.db.sql.zeos, line 694
sTableName := meta.AddEscapeCharToWildcards(sTableName); // <---- this line should be removed, because AddEscapeCharToWildcards is called TWICE!
// do not escape https://synopse.info/forum/viewtopic.php?pid=34896#p34896
res := meta.GetColumns('', sSchema,
meta.AddEscapeCharToWildcards(sTableName), '');
Last edited by wxinix (2021-05-16 13:15:23)
Offline
I have fixed TSqlDBZeosConnectionProperties.GetFields as you proposed.
About https://github.com/synopse/mORMot2/issues/33 please see my remark.
By design, GetJsonField() does not support JSON objects or arrays.
It only parses simple values.
I don't understand what is your use case of JsonToObject.
Could you please show a class definition which has problem be parsed?
Offline
Pages: 1