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

Using like operator for queries has issues #46

Closed
Emperoni opened this issue Feb 29, 2016 · 4 comments
Closed

Using like operator for queries has issues #46

Emperoni opened this issue Feb 29, 2016 · 4 comments

Comments

@Emperoni
Copy link

In order to use like with % such as '%prepaid inventory' I have had to pass it as '%25prepaid inventory' and on line 1925 of index.js I've had to comment out:
url.replace(/%/g, '%25')

this section only changes the first occurrence anyway, so it is ineffective at replacing all characters.

I am using the like operator as follows:

accountsQuery = '%25Prepaid Inventory'
qbo.findAccounts([{field: 'Name', value: accountsQuery, operator: 'LIKE'}], function(err, account)

@mcohen01
Copy link
Owner

mcohen01 commented Mar 2, 2016

qbo.findAccounts([
  {
    field: 'Name',
    value: '%Prepaid Inventory',
    operator: 'LIKE'
  }
], function(e, data) {
  console.log(JSON.stringify(data, null,2))
  done()
})

doesn't give me any errors.

Regarding L1925 of index.js, url = url.replace(/%/g, '%25') will greedily replace all % characters in the string with %25.

Sorry, I'm not sure what problem you're running into here.

@Emperoni
Copy link
Author

Emperoni commented Mar 2, 2016

Thank you so much for the reply. Let me explain my issue.
If I submit '%Prepaid Inventory%' (with two % signs) the API somehow replaces characters and submits:
uri: 'https://quickbooks.api.intuit.com/v3/company/409491146/query?query=select%2520*%2520from%2520account%2520where%2520Name%2520LIKE%2520%2527%2525Prepaid%2520Inventory%25%2527',
which is obviously messed up and returns:
Message: 'Error parsing query',
Detail: 'QueryParserError: Invalid content. Lexical error at line 1, column 7. Encountered: "%" (37), after : ""',

what happened above, among other things, is that each space is replaced with %20, and then %20 is replaced with %2520.

I don't think that this is your code doing it. Does this mean that I cannot submit a LIKE with two % signs?

Thanks!

@mcohen01
Copy link
Owner

mcohen01 commented Mar 2, 2016

I would delete node_modules/node-quickbooks and then npm install node-quickbooks --save again and see what you get

@Emperoni
Copy link
Author

Emperoni commented Mar 2, 2016

Thank you for your time! That did it. My bad, I should have updated first.

@Emperoni Emperoni closed this as completed Mar 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants