#1 2015-06-19 08:14:08

lagodny
Member
Registered: 2015-01-28
Posts: 50

LEFT JOIN, RIGHT JOIN... etc

mORMot.pas
function SQLFromWhere(const Where: RawUTF8): RawUTF8;

Could you add a check for LEFT, RIGHT, INNER, OUTER JOIN?

And could you exclude spaces before this and other keywords.
For example, ' where 1 = 1' - doesn't work correctly.

Offline

#2 2015-06-19 08:44:37

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

Re: LEFT JOIN, RIGHT JOIN... etc

AFAIK you should not put the 'where' keyword in the Where parameter.
About '1 = 1', I do not understand your point. It would depend on the method. Have you code to reproduce it? Some methods expect a true field name to be supplied, e.g. fieldname=value, and would check for the fieldname.

For a JOIN, you would need to have a reference to two (or more) tables, which is not the context of SQLFromWhere(), which applies to a single table.
For JOIN, you should use http://synopse.info/files/html/Synopse% … l#TITL_129
But only default mode is LEFT JOIN, for the ORM.

For most complex queries, you may just run the plain SQL, without the ORM.
Take a look at TSQLRest.ExecuteList().

Anyway, I've updated SQLFromWhere() to identify LEFT, RIGHT, INNER, OUTER JOIN clauses.
See http://synopse.info/fossil/info/241c94dc8d

Offline

#3 2015-06-19 10:58:10

lagodny
Member
Registered: 2015-01-28
Posts: 50

Re: LEFT JOIN, RIGHT JOIN... etc

Thank you. it's enough

Offline

Board footer

Powered by FluxBB