drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
24.68k stars 651 forks source link

[BUG]:"Encoding not recognized: 'undefined' (searched as: 'undefined')" issue #3548

Open freddyy2024 opened 1 week ago

freddyy2024 commented 1 week ago

Report hasn't been filed before.

What version of drizzle-orm are you using?

0.36.1

What version of drizzle-kit are you using?

0.28.0

Other packages

"mysql2": "^3.11.4",

Describe the Bug

`
import { statActionLog } from "~/drizzle/schema"; import { db } from "../db/database" import { datetime } from "drizzle-orm/mysql-core"

// some other code to init the save data // .......

const currentTime = new Date();

const data: StatActionLog = {
    referer,
    requestUrl,
    userAgent,
    clientIp,
    createTime: currentTime,
}

const result = await db.insert(statActionLog).values(data).$returningId();
console.log(JSON.stringify(result))

`

The insert data: { referer: 'http://localhost:3000/', requestUrl: '/api/download', userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36', clientIp: '127.0.0.1', createTime: 2024-11-13T19:42:24.857Z }

The fisrt time is success, when called the second time, report below issue:

"message":"Encoding not recognized: 'undefined' (searched as: 'undefined')"