Wappler Version : 3.0.1 NodeJS
Operating System : Windows 10
Expected behavior
When you create a standard DB query with at least 1 other INNER JOIN, you should be able to use a WHERE condition to filter the results using a column from the 2nd (or 3rd, 4th etc) table that you have joined.
…
Actual behavior
When you create a query with multiple tables, and start to place WHERE conditions on the query, it will break the moment you use a column from any of the additional tables you have created a JOIN on.
i.e. If you just use columns from your primary table, the query will still work. But if you use a column from any of the joined tables it will error with the below error details.
NB. This only happened on the standard query builder. If you write a custom query it works as expected.
How to reproduce
Create a standard DB query on a NodeJS project
-Add at least one other table and create an INNER JOIN
-Add a CONDITION using a column from any of the additional joined tables
-Run query / check error.
I seem to be getting lots of 500 errors with my server connects in NodeJS, some to do with joined tables, too. So just adding to the importance of this.
Hey @mgaussie Just on this, I’m not having any issues with running queries with multiple joins, as long as the conditions are only from the original table.
So if you’ve got some extra conditions that might be your problem? Worthwhile to test out at least
I did some testing and the conditions work fine with joins. Problem seems to be when the parameter is not set, then the error is displayed. Will see if we can handle that better.
Here is the error: {"status":"500","code":"42P01","message":"select count(*) as \"Total\" from \"users\" where \"teams\".\"id\" = $1 limit $2 - missing FROM-clause entry for table \"teams\"","stack":"error: select count(*) as \"Total\" from \"users\" where \"teams\".\"id\" = $1 limit $2 - missing FROM-clause entry for table \"teams\"\n at Parser.parseErrorMessage (S:\\app_development\\dev\\node_modules\\pg-protocol\\dist\\parser.js:241:15)\n at Parser.handlePacket (S:\\app_development\\dev\\node_modules\\pg-protocol\\dist\\parser.js:89:29)\n at Parser.parse (S:\\app_development\\dev\\node_modules\\pg-protocol\\dist\\parser.js:41:38)\n at Socket.<anonymous> (S:\\app_development\\dev\\node_modules\\pg-protocol\\dist\\index.js:8:42)\n at Socket.emit (events.js:310:20)\n at addChunk (_stream_readable.js:286:12)\n at readableAddChunk (_stream_readable.js:268:9)\n at Socket.Readable.push (_stream_readable.js:209:10)\n at TCP.onStreamRead (internal/stream_base_commons.js:186:23)"}
{"status":"500","code":"42P01","message":"select count(*) as \"Total\" from \"users\" where \"teams\".\"id\" = $1 limit $2 - missing FROM-clause entry for table \"teams\"","stack":"error: select count(*) as \"Total\" from \"users\" where \"teams\".\"id\" = $1 limit $2 - missing FROM-clause entry for table \"teams\"\n at Parser.parseErrorMessage (S:\\app_development\\dev\\node_modules\\pg-protocol\\dist\\parser.js:241:15)\n at Parser.handlePacket (S:\\app_development\\dev\\node_modules\\pg-protocol\\dist\\parser.js:89:29)\n at Parser.parse (S:\\app_development\\dev\\node_modules\\pg-protocol\\dist\\parser.js:41:38)\n at Socket.<anonymous> (S:\\app_development\\dev\\node_modules\\pg-protocol\\dist\\index.js:8:42)\n at Socket.emit (events.js:310:20)\n at addChunk (_stream_readable.js:286:12)\n at readableAddChunk (_stream_readable.js:268:9)\n at Socket.Readable.push (_stream_readable.js:209:10)\n at TCP.onStreamRead (internal/stream_base_commons.js:186:23)"}
I’m attempting to do the same as Philip, however with a LEFT join, not just Inner - everything works fine on the first table, just not any joined tables.