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.
Here is a shot of the query i built:
Here is the error message:
{"status":"500","message":"Undefined binding(s) detected when compiling SELECT. Undefined column(s): [name.name] query: select
agents.
first_name,
agents.
last_name,
agents.
work_phone,
agents.
work_email,
agents.
employee_id,
agents.
last_updatefrom
agentsinner join
teamsas
nameon
name.
id=
agents.
team_idwhere
name.
name= ?","stack":"Error: Undefined binding(s) detected when compiling SELECT. Undefined column(s): [name.name] query: select
agents.
first_name,
agents.
last_name,
agents.
work_phone,
agents.
work_email,
agents.
employee_id,
agents.
last_updatefrom
agentsinner join
teamsas
nameon
name.
id=
agents.
team_idwhere
name.
name = ?\n at QueryCompiler_MySQL.toSQL (C:\\Switchley\\nodeJS\\demo\\node_modules\\knex\\lib\\query\\compiler.js:99:13)\n at Builder.toSQL (C:\\Switchley\\nodeJS\\demo\\node_modules\\knex\\lib\\query\\builder.js:72:44)\n at C:\\Switchley\\nodeJS\\demo\\node_modules\\knex\\lib\\runner.js:31:36\n at C:\\Switchley\\nodeJS\\demo\\node_modules\\knex\\lib\\runner.js:260:24\n at processTicksAndRejections (internal/process/task_queues.js:97:5)\n at async App._exec (C:\\Switchley\\nodeJS\\demo\\lib\\core\\app.js:224:30)\n at async App._exec (C:\\Switchley\\nodeJS\\demo\\lib\\core\\app.js:206:17)\n at async App.exec (C:\\Switchley\\nodeJS\\demo\\lib\\core\\app.js:177:9)\n at async App.define (C:\\Switchley\\nodeJS\\demo\\lib\\core\\app.js:160:9)"}