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.

Duplicate input and/or output query params results in undefined behavior

See original GitHub issue

Spinning this off from #634.

If request.input() param names match request.output() param names in the same request.query(), there is no error thrown, but the result may not be what the user expected.

This bit me when I was trying to do a SELECT and had used the same @name param as a column return value and a bind-argument:

    const name = 'test-user';
    const result = await pool
      .request()
      .input('name', sql.VarChar(255), name)
      .output('id', sql.BigInt)
      .output('name', sql.VarChar(255))
      .output('created_on', sql.DateTime2(3))
      .query(`SELECT TOP 1 [id], [name], [created_on] FROM users WHERE name = @name`);
    if (result.recordsets.length !== 1 || result.recordsets[0].length !== 1) {
      // no results
      return;
    }
    const row = result.recordsets[0][0];
    console.log(`#${row.id}, ${row.name}`);

To fix the issue, I changed input('name', ...) to input('name_query', ...) and @name to @name_query. It may be nice to throw some error here if that happens? Maybe log a warning?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:5

github_iconTop GitHub Comments

1reaction
dhensbycommented, Mar 8, 2019

ah, ok. that’s a bit annoying!

0reactions
dhensbycommented, Mar 12, 2019

I would make clear, however, it’s best to properly type your bulk data rather than relying on the library to do it

Read more comments on GitHub >

github_iconTop Results From Across the Web

Undefined values causing problems with inputs #52 - GitHub
I have a component Filter which the user interacts with through input controls in order to specify a filter, which should then be...
Read more >
Undefined when returning 'results' parameter from mysql query
So why data is equal to 'undefined' if i'm returning the 'results' array? and how can i solve this? I'm new in Node.js,...
Read more >
Under-Constrained Symbolic Execution with Crucible
Sure, perhaps your library function my_div has undefined behavior when it's second argument is zero, but that's probably expected, it might even ...
Read more >
Sure, multiple query params with the same name are...
So the outcome is consistent: multiple params with the same name become an Array, which is then stringified using the default JS behavior...
Read more >
CGI - Simple Common Gateway Interface Class
print $query->textfield('field_name','starting value',50,80);. textfield() will return a text input field. Parameters: The first parameter is the required name ...
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