question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Query with params throwing ERR_INVALID_ARG_TYPE

See original GitHub issue

Issue Description

When i run a query with params example: Test.find({ where: { id } }); Im gettting the following error: originalError: QueryFailedError: Error: The “string” argument must be of type string or an instance of Buffer or ArrayBuffer. Received type number (0) code: ERR_INVALID_ARG_TYPE When i try to use a QueryBuilder passing the argument directly Test.createQueryBuilder('test').where('id = ${id}').getOne(); this works perfectly

Expected Behavior

return the query result

Actual Behavior

originalError: QueryFailedError: Error: The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received type number (0)
code: ERR_INVALID_ARG_TYPE
`Test.find({ where: { id } });`

query failed: SELECT "test"."id" AS "test_id", "test"."test_name" AS "test_test_name", "test"."test_lastname" AS "test_test_lastname" FROM "dbo"."test" "test" WHERE id = @0 -- PARAMETERS: [1]

My Environment

Dependency Version
Operating System ubuntu
Node.js version v14.17.2
Typescript version typescript@4.0.5
TypeORM version typeorm@0.2.29

Additional Context

Relevant Database Driver(s)

DB Type Reproducible
aurora-data-api no
aurora-data-api-pg no
better-sqlite3 no
cockroachdb no
cordova no
expo no
mongodb no
mysql no
nativescript no
oracle no
postgres no
react-native no
sap no
sqlite no
sqlite-abstract no
sqljs no
sqlserver yes

Are you willing to resolve this issue by submitting a Pull Request?

  • ✖️ Yes, I have the time, and I know how to start.
  • ✖️ Yes, I have the time, but I don’t know how to start. I would need guidance.
  • ✖️ No, I don’t have the time, but I can support (using donations) development.
  • ✅ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
imnotjamescommented, Aug 11, 2021

When opening an issue, people will be better able to provide help if you provide code that they can easily understand and use to reproduce the problem. This boils down to ensuring your code that reproduces the problem follows the following guidelines:

  • Minimal – Use as little code as possible that still produces the same problem
  • Complete – Provide all parts someone else needs to reproduce your problem in the question itself
  • Reproducible – Test the code you’re about to provide to make sure it reproduces the problem

Minimal

The more code there is to go through, the less likely people can find your problem. Streamline your example in one of two ways:

  1. Restart from scratch. Create a new program, adding in only what is needed to see the problem. Use simple, descriptive names for functions and variables – don’t copy the names you’re using in your existing code.
  2. Divide and conquer. If you’re not sure what the source of the problem is, start removing code a bit at a time until the problem disappears – then add the last part back.

Don’t sacrifice clarity for brevity when creating a minimal example. Use consistent naming and indentation, and include code comments if needed. Use your code editor’s shortcut for formatting code.

Don’t include any passwords or credentials that must be kept secret.

Complete

Make sure all information necessary to reproduce the problem is included in the issue itself.

If the problem requires some code as well as some XML-based configuration, include code for both. The problem might not be in the code that you think it is in.

Use individual code blocks for each file or snippet you include. Provide a description for the purpose of each block.

DO NOT use images of code. Copy the actual text from your code editor, paste it into the issus, then format it as code. This helps others more easily read and test your code.

Reproducible

To help you solve your problem, others will need to verify that it exists.

Describe the problem. “It doesn’t work” isn’t descriptive enough to help people understand your problem. Instead, tell other readers what the expected behavior should be. Tell other readers what the exact wording of the error message is, and which line of code is producing it. Use a brief but descriptive summary of your problem as the title of your question.

Eliminate any issues that aren’t relevant to the problem. If your question isn’t about a compiler error, ensure that there are no compile-time errors.

Double-check that your example reproduces the problem! If you inadvertently fixed the problem while composing the example but didn’t test it again, you’d want to know that before asking someone else to help.

0reactions
vv619-perfcommented, Oct 18, 2022

@srwilliamg Were you able to resolve the issue, is it by downgrading the mssql to “^6.3.2”.

Could you please provide the respective versions of the below modules if you have used:

  • typeorm
  • mssql
  • tedious
Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument ...
I thought the error was telling me that path was undefined. ... The "key" argument must be one of type string, TypedArray, or...
Read more >
TypeError [ERR_INVALID_ARG_TYPE] · Issue #8499 - GitHub
Started getting TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined in multiple CRA ...
Read more >
Errors | Node.js v19.3.0 Documentation
js will generate and throw RangeError instances immediately as a form of argument validation. Class: ReferenceError #. Extends: <errors.Error>. Indicates that ...
Read more >
SyntaxError: missing ) after argument list - JavaScript | MDN
The JavaScript exception "missing ) after argument list" occurs when there is an error with how a function is called. This might be...
Read more >
SQL compilation error: Invalid argument types for function ...
This article explains why we receive a SQL compilation error: Invalid argument types for function 'TYPEOF' while using the TYPEOF Function.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found