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

SQLITE_MISUSE when attempting to use with Knex #6

Closed
penberg opened this issue Jun 11, 2023 · 2 comments
Closed

SQLITE_MISUSE when attempting to use with Knex #6

penberg opened this issue Jun 11, 2023 · 2 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@penberg
Copy link
Contributor

penberg commented Jun 11, 2023

I have the following index.js:

const Knex = require("knex");
const Client_SQLite3 = require("knex/lib/dialects/sqlite3");

class Client_Libsql extends Client_SQLite3 {
    _driver() {
        return require("@libsql/sqlite3");
    }
}

const knex = Knex({
    client: Client_Libsql,
    connection: {
        filename: "file:hello.db",
    },
});

knex.table('users').first().then((data) => {
    console.log(data);
});

and the following package.json:

{
  "name": "knex-testing",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@libsql/sqlite3": "^0.2.1",
    "knex": "^2.4.2",
    "sqlite3": "^5.1.6"
  }
}

fails as follows:

penberg@vonneumann knex-testing % node index.js
sqlite does not support inserting default values. Set the `useNullAsDefault` flag to hide this warning. (see docs https://knexjs.org/guide/query-builder.html#insert).
node:internal/process/promises:279
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[Error: SQLITE_MISUSE: bad parameter or other API misuse] {
  errno: 21,
  code:
@penberg penberg added bug Something isn't working help wanted Extra attention is needed labels Jun 11, 2023
@glommer
Copy link

glommer commented Jun 11, 2023

We're calling Database() with mode = 0.

Knex is passing 0, which it obviously doesn't for main SQLite. So no idea why

Flagging @honzasp

@honzasp honzasp self-assigned this Jun 12, 2023
@honzasp
Copy link
Contributor

honzasp commented Jun 12, 2023

Fixed: baceb05
I used for in instead of for of when exporting named constants from the package :(

@honzasp honzasp closed this as completed Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants