简体   繁体   中英

SQL Query returns Buffer on DATE field using knexJS

I'm executing a sql query using knexJS, and i have this line:

this.knex.raw("CONCAT(DATE_FORMAT(xalog2.date, '%Y-%m-%d'),' ', SEC_TO_TIME(xalog2.time)) AS EMISSAO")

It's a simple query to get date and concat with time. But, i'm facing through a ploblem: locally, i'm receiving a string on the way it should be. like: '2019-02-07 02:02:00'. When i run the same query, but now on the docker client, i'm receiving it:

"EMISSAO": {
"type": "Buffer",
"data": [
50,
48,
49,
56,
45,
48,
49,
45,
50,
57,
32,
49,
49,
58,
49,
50,
58,
53,
53
]
}

Any ideas? Thank you.

Adding a CAST solved the problem. CAST(CONCAT(DATE_FORMAT(xalog2.date, '%Y-%m-%d'),' ', SEC_TO_TIME(xalog2.time)) AS CHAR) AS EMISSAO

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM