修复数据库中反斜杠转义问题

This commit is contained in:
2025-03-13 09:07:58 +08:00
parent c5e5a1e251
commit 1896efa891
3 changed files with 4 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@yizhi/postgres", "name": "@yizhi/postgres",
"version": "1.0.14", "version": "1.0.16",
"main": "dist/index.js", "main": "dist/index.js",
"types": "typing/index.d.ts", "types": "typing/index.d.ts",
"scripts": {}, "scripts": {},

View File

@ -161,8 +161,8 @@ export function Field(typename: string, name: string | undefined, encode: IEntit
* @param name 字段名称 * @param name 字段名称
* @param option 字段选项 * @param option 字段选项
*/ */
export function IntColumn(name: string, option?: { primary: boolean, virtual?: boolean }): Decorators.PropDecorator<BasicEntity> export function IntColumn(name: string, option?: { primary?: boolean, virtual?: boolean }): Decorators.PropDecorator<BasicEntity>
export function IntColumn(option?: { primary: boolean, virtual?: boolean }): Decorators.PropDecorator<BasicEntity> export function IntColumn(option?: { primary?: boolean, virtual?: boolean }): Decorators.PropDecorator<BasicEntity>
export function IntColumn(name?: any, option?: any) { export function IntColumn(name?: any, option?: any) {
if (typeof name != "string") { if (typeof name != "string") {
option = name; option = name;

View File

@ -6,7 +6,7 @@ export function escapeID(...keys: string[]) {
export function escapeValue(value: any) { export function escapeValue(value: any) {
if (typeof value === "number") return value.toString(); if (typeof value === "number") return value.toString();
else if (typeof value === "string") return `E'${(value).replaceAll("'", "\\x27")}'`; else if (typeof value === "string") return `E'${(value).replaceAll("'", "\\x27").replaceAll("\\", "\\x5c")}'`;
else if (typeof value === "boolean") return value.toString(); else if (typeof value === "boolean") return value.toString();
else if (typeof value === "bigint") return value.toString(); else if (typeof value === "bigint") return value.toString();
else if (value === null) return "null"; else if (value === null) return "null";