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

TypeError: sql.trim is not a function #410

Closed
dtbuchholz opened this issue Feb 22, 2023 · 4 comments
Closed

TypeError: sql.trim is not a function #410

dtbuchholz opened this issue Feb 22, 2023 · 4 comments

Comments

@dtbuchholz
Copy link
Contributor

Describe the bug
I'm trying to chunk queries into batches so that I can be under the 35kb limit. In doing so, I ran into an error TypeError: sql.trim is not a function, but I'm not using that function in my code.

To Reproduce
Here's a gist of the code: https://gist.github.com/dtbuchholz/5264be5c7081268a7ddee864bad8ec03

I'm not necessarily sure if the chunking process is correct, but that doesn't matter—the sql.trim is not a function shouldn't appear for me. Here's the exact errror:

file:///Users/dtb/Desktop/t/node_modules/@tableland/sdk/dist/esm/statement.js:27
        this.sql = sql.trim();
                       ^

TypeError: sql.trim is not a function
    at new Statement (file:///Users/dtb/Desktop/t/node_modules/@tableland/sdk/dist/esm/statement.js:27:24)
    at Database.prepare (file:///Users/dtb/Desktop/t/node_modules/@tableland/sdk/dist/esm/database.js:49:16)
    at main (file:///Users/dtb/Desktop/t/t.js:51:37)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Desktop (please complete the following information):

  • OS: Mac M1
  • Node: v18.12.1
  • SDK: ^4.0.0-pre.8
  • Local Tableland: ^1.0.0-pre.4
@carsonfarmer
Copy link
Member

Is it possible that your function is creating an undefined input into the prepare statement? Clearly we need to catch this potential error, that but seems like it might be the cause (because if it were a valid string, then sql.trim() would be a function).

@dtbuchholz
Copy link
Contributor Author

Definitely possible. I just wanted to share the error.

@joewagner
Copy link
Contributor

Looks like the value of statement is [ undefined ], which obviously isn't a string. I'll open a PR to pass a more human friendly error message in a second.

@joewagner
Copy link
Contributor

fixed by #411

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

3 participants