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

JSError: conversion specifier \"%d\" at character 3 has no matching argument (too few arguments passed) #1277

Closed
perry-mitchell opened this issue Jan 14, 2021 · 2 comments

Comments

@perry-mitchell
Copy link

perry-mitchell commented Jan 14, 2021

Hi,

I'm getting an error running the following prepared query using mysql2 (2.2.5) against MySQL 8.0.21:

SELECT
    company_id AS companyID,
    DATE_FORMAT(created, "%Y-%m-%d") AS `day`,
    SUM(unique_chats) AS uniqueChats,
    SUM(successful_chats) AS successfulChats,
    SUM(visitor_left) AS visitorLeft,
    SUM(sent_messages) AS sentMessages,
    SUM(received_messages) AS receivedMessages,
    SUM(all_messages) AS allMessages
FROM a_hourly
WHERE
    company_id = ? AND
    created BETWEEN ? AND ?
GROUP BY `day`

The error I get is the following:

Error: format string \"Failed executing query: \"SELECT
        company_id AS companyID,
        DATE_FORMAT(created, \"%Y-%m-%d\") AS `day`,
        SUM(unique_chats) AS uniqueChats,
        SUM(successful_chats) AS successfulChats,
        SUM(visitor_left) AS visitorLeft,
        SUM(sent_messages) AS sentMessages,
        SUM(received_messages) AS receivedMessages,
        SUM(all_messages) AS allMessages
    FROM a_hourly
    WHERE
        company_id = ? AND
        created BETWEEN ? AND ?
    GROUP BY `day`\" [2, 2021-01-13T00:00:00Z, 2021-01-14T23:59:59Z]\": conversion specifier \"%d\" at character 3 has no matching argument (too few arguments passed)
at jsError (/data/node_modules/extsprintf/lib/extsprintf.js:173:10)
at jsSprintf (/data/node_modules/extsprintf/lib/extsprintf.js:97:11)
at parseConstructorArguments (/data/node_modules/verror/lib/verror.js:120:26)
at new VError (/data/node_modules/verror/lib/verror.js:153:11)
at ConnectionPool.<anonymous> (/data/node_modules/@leadoo/mysql-connection-pool/dist/ConnectionPool.js:128:27)
at Generator.throw (<anonymous>)
at rejected (/data/node_modules/@leadoo/mysql-connection-pool/dist/ConnectionPool.js:6:65)
at processTicksAndRejections (internal/process/task_queues.js:93:5)

However:

  • If I run this exact query in MySQL workbench, for instance, it works
  • If I change from execute to query mode, it works

Could this possibly be related to #1239 ? Some how the statement preparation is failing on the data I'm passing in?

I'm on Node 14, running everything from within Docker containers.

EDIT: In the segment DATE_FORMAT(created, \"%Y-%m-%d\") AS day, created is a TIMESTAMP.

@sidorares
Copy link
Owner

@perry-mitchell are you sure you are using mysql2 driver? Do you know what's the repo for @leadoo/mysql-connection-pool ? Your error is coming from extsprintf package that is not used by this driver.

@perry-mitchell
Copy link
Author

@sidorares That connection pool simply returns a mysql2 instance, without modifying it. That being said, you're right, I can see that extsprintf is from the verror library I'm using. It was obscuring the error, which was just a non-aggregated column issue.

Really sorry for wasting your time!

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