Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only debug mode : Undefined binding(s) detected when compiling WHERE. Undefined column(s): [t0.id] query: where t0.id = ? #20313

Closed
benramsay opened this issue May 15, 2024 · 1 comment
Labels
flag: question Automation Flag to handle community questions

Comments

@benramsay
Copy link

benramsay commented May 15, 2024

  • Node.js version: 20.13.0
  • NPM version:10.5.2
  • Strapi version:4.24.2
  • Database:mysql
  • Operating system:mac
  • Is your project Javascript or Typescript:Javascript

The bug

When I am in DEBUG mode and stop on breakpoints, I encounter the following error, and the entire process stops. However, if I don't set breakpoints and only use console.log(...), everything proceeds as expected, without errors.

The error displayed when the system crashes is as follows:

Error: Undefined binding(s) detected when compiling WHERE. Undefined column(s): [t0.id] query: where t0.id = ?

It seems to occur after this line of code:

const user = await getService("user").fetchAuthenticatedUser(id);

But the "id" is provided correctly, and the user exists in the database.

What could explain that this error only occurs in debug mode, and when I run the project with 'npm run develop', for example, or without be stopped on breakpoints, I don't encounter any error?

--
More details to help understand the problem:

In the following image, you can see that the breakpoint is set after the three equivalent calls to the database. Everything works well, and I hit the breakpoint as expected, with the correct log appearing on the console.

image

Now, if I change the breakpoint to an upper level, as shown in the following image, and then stop at this breakpoint, attempting to proceed instruction by instruction will terminate the process upon the first call to the database. This occurs precisely at this breakpoint, regardless of the order of the three database calls.

image

The error I will have is the following:

/path_to_my_project/node_modules/knex/lib/query/querycompiler.js:112
throw new Error(
^

Error: Undefined binding(s) detected when compiling WHERE. Undefined column(s): [t0.id] query: where t0.id = ?
at QueryCompiler_MySQL.toSQL (/path_to_my_project/node_modules/knex/lib/query/querycompiler.js:112:13)
at compileCallback (/path_to_my_project/node_modules/knex/lib/formatter/formatterUtils.js:13:19)
at rawOrFn (/path_to_my_project/node_modules/knex/lib/formatter/wrappingFormatter.js:225:7)
at QueryCompiler_MySQL.whereWrapped (/path_to_my_project/node_modules/knex/lib/query/querycompiler.js:1095:17)
at QueryCompiler_MySQL.where (/path_to_my_project/node_modules/knex/lib/query/querycompiler.js:584:34)
at /path_to_my_project/node_modules/knex/lib/query/querycompiler.js:135:40
at Array.forEach ()
at QueryCompiler_MySQL.select (/path_to_my_project/node_modules/knex/lib/query/querycompiler.js:134:16)
at QueryCompiler_MySQL.toSQL (/path_to_my_project/node_modules/knex/lib/query/querycompiler.js:75:29)
at Builder.toSQL (/path_to_my_project/node_modules/knex/lib/query/querybuilder.js:84:44)

@derrickmehaffy derrickmehaffy added the flag: question Automation Flag to handle community questions label May 31, 2024
Copy link
Contributor

This is a templated message

Hello @benramsay,

I see you are wanting to ask a question that is not really a bug report,

Please see the following contributing guidelines for asking a question here.

Thank you.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flag: question Automation Flag to handle community questions
Projects
Status: Done
Development

No branches or pull requests

2 participants