Mjoin error with Postgres
Mjoin error with Postgres
Hello,
maybe someone can help me. It looks for me like there is a failure in the table name escape if you use Mjoin.
I have a table with 2 left join and one multiple join.
The left join's are working as expected.
Now I have added the mjoin:
->leftJoin( 'PortgroupsStatus', 'PortgroupsStatus.id', '=', 'Portgroups.id_Status' )
->leftJoin( 'PortgroupConnectiontype', 'PortgroupConnectiontype.id', '=', 'Portgroups.id_Contype' )
->join(
Mjoin::inst( 'AdminSegmentTypes' )
->link( 'Portgroups.id', 'n2n_portgroup_destination2nettype.id_portgroup_dest' )
->link( 'AdminSegmentTypes.id', 'n2n_portgroup_destination2nettype.id_nettype' )
->order( 'name asc' )
->fields(
Field::inst( 'id' )
->validator( Validate::required() )
->options( Options::inst()
->table( 'AdminSegmentTypes' )
->value( 'id' )
->label( 'name' )
),
Field::inst( 'name_destination' )
)
)
But I got an error:
an SQL error occurred: SQLSTATE[42P01]: Undefined table: 7 FEHLER: Relation »portgroups« existiert nicht\nLINE 1: ...s\".\"name_destination\" as \"name_destination\" FROM Po...\n
Debug output:
query: "SELECT DISTINCT \"Portgroups\".\"id\" as \"dteditor_pkey\", \"AdminSegmentTypes\".\"id\" as \"id\", \"AdminSegmentTypes\".\"name_destination\" as \"name_destination\" FROM Portgroups as Portgroups JOIN \"n2n_portgroup_destination2nettype\" ON \"Portgroups\".\"id\" = \"n2n_portgroup_destination2nettype\".\"id_portgroup_dest\" JOIN \"AdminSegmentTypes\" ON \"AdminSegmentTypes\".\"id\" = \"n2n_portgroup_destination2nettype\".\"id_nettype\" WHERE \"Portgroups\".\"id\" IN (:wherein1, :wherein2,) ORDER BY \"name\" asc
The name of the table is not correct escaped anymore. Postgres now use lower case (portgroups instead of Portgroups).
For the other joins it is correct.
I have installed the last Editor version 2.07 and also 2.06.
This question has an accepted answers - jump to answer
Answers
That is certainly the problem in the SQL. Postgres will fold unescaped identifiers down to lowercase.
You note you are using Editor 2.0.7 - are you using the 2.0.7 PHP libraries on the server-side as well (search in Editor.php for version)? The reason I ask is that with some of the newer updates the
as
shouldn't be there any more, which makes me think you might have older PHP libraries for Editor.Regards,
Allan
Hello Allan,
thanks for support.
The version number I see in the Editor.php is
Could you check that this line is in the corresponding copy that you have? That is what should be stripping the
as
which is appearing in your debug.Aside from that, honestly I'm not sure! I would probably need a clone of your project or access to the system to find the difference.
Allan
Sorry for the late reply.
I found a failure in my autoloader so that the version 2.0.5 was used. - Fixed now.
But also in the new version it will not escape the table names correct. But this time not during the join
Still
instead of
I cannot clone the application
Here it the code of the application:
Many thanks. I've just tried running it locally and this is the SQL for the four queries it generates:
I don't have your database schema here, but looking at the queries, that looks correct I think. If you run them against your db, do they complete successfully?
If so, it suggests to me that the PHP libraries we are using are slightly different. Perhaps you could download the very latest from github and try them?
Thanks,
Allan
Hi Alan,
your SQL commands are working as you have expected.
I have to find the difference in my environment.
Thanks for support.