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

GoError: unsupported database: invalid driver parameter type #115

Open
gweyeratlassian opened this issue Feb 2, 2025 · 3 comments
Open

Comments

@gweyeratlassian
Copy link

I have a basic test that write to PostgreSQL. If I run it directly using k6, it works. If I transpile and bundle it, it fails with the below error:

ERRO[0000] GoError: unsupported database: invalid driver parameter type
	at reflect.methodValueCall (native)

I added a test to https://github.com/grafana/k6-template-es6 (I realize this is deprecated, but it uses similar tooling than the code base I'm trying to fix).

The test in question:

import sql from "k6/x/sql";
import driver from "k6/x/sql/driver/postgres";

const db = sql.open(driver, "");

export function setup() {
}

export function teardown() {
  db.close();
}

export default function () {
  let result = db.exec(`
    INSERT INTO roster
      (given_name, family_name)
    VALUES
      ('Peter', 'Pan');
  `);
  console.log(`${result.rowsAffected()} rows inserted`);

  let rows = db.query("SELECT * FROM roster WHERE given_name = $1;", "Peter");
  for (const row of rows) {
    console.log(`${row.family_name}, ${row.given_name}`);
  }
}

When I run ./k6 run src/postgres-test.js, it works as expected. But if I run ./k6 run dist/postgres-test.js (the bundled file), it fails with the error aforementioned.

I'v tried different version of JavaScript (from 14 to 22) and different versions of k6 (from 45 to 55). The issue seems to be specific to "k6/x/sql/driver/postgres" (e.g. my code can call sql.open).

Configuration:

k6 v0.55.0 (commit/e43ec7cfba-dirty, go1.23.5, darwin/arm64)
Extensions:
  github.com/grafana/xk6-sql v1.0.1, k6/x/sql [js]
  github.com/grafana/xk6-sql v1.0.1, k6/x/sql/driver/mysql [js]
  github.com/grafana/xk6-sql v1.0.1, k6/x/sql/driver/postgres [js]
  github.com/grafana/xk6-sql v1.0.1, k6/x/sql/driver/sqlserver [js]
@szkiba
Copy link
Contributor

szkiba commented Feb 13, 2025

Hi @gweyeratlassian , Thank you for reporting this.

Could you please attach the bundled file? I suspect that the driver type parameter got corrupted during the bundling process.

@gweyeratlassian
Copy link
Author

gweyeratlassian commented Feb 13, 2025

I've generated the bundle multiples times so it would indicate an issue with xk6 or the command I'm running? This is the command I used:

xk6 build \
  --with github.com/grafana/xk6-sql@latest \
  --with github.com/grafana/xk6-sql-driver-mysql \
  --with github.com/grafana/xk6-sql-driver-postgres \
  --with github.com/grafana/xk6-sql-driver-sqlserver

I'm running on macOS Sequoia 15.2 if that makes a difference.

Edit: sorry I thought you were interested in the k6 binary, but you probably wanted the JavaScript bundled. I attached it now.

k6.zip
postgres-test.js.zip

@harrynguyen-tw
Copy link

harrynguyen-tw commented Feb 19, 2025

I got the same issue with postgres driver. I did compile test cases from Typescript to JavaScript and fail with error unsupported database: invalid driver parameter type. It used to work before the breaking changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants