fix: pg types conversion dbstudio (#3636)

This commit is contained in:
HugoCasa
2024-04-29 22:34:43 +02:00
committed by GitHub
parent ca49e273de
commit f6e8f45af1
2 changed files with 7 additions and 7 deletions
@@ -12,9 +12,9 @@ function deleteWithAllValues(table: string, columns: ColumnDef[], dbType: DbType
const conditions = columns
.map(
(c, i) =>
`($${i + 1}::${c.datatype} IS NULL AND ${c.field} IS NULL OR ${c.field} = $${i + 1}::${
c.datatype
})`
`($${i + 1}::text::${c.datatype} IS NULL AND ${c.field} IS NULL OR ${c.field} = $${
i + 1
}::text::${c.datatype})`
)
.join('\n AND ')
@@ -25,13 +25,13 @@ function updateWithAllValues(
const conditions = columns
.map(
(c, i) =>
`($${i + 2}::${c.datatype} IS NULL AND ${c.field} IS NULL OR ${c.field} = $${i + 2}::${
c.datatype
})`
`($${i + 2}::text::${c.datatype} IS NULL AND ${c.field} IS NULL OR ${c.field} = $${
i + 2
}::text::${c.datatype})`
)
.join('\n AND ')
query += `\nUPDATE ${table} SET ${column.field} = $1::${column.datatype} \nWHERE ${conditions} RETURNING 1`
query += `\nUPDATE ${table} SET ${column.field} = $1::text::${column.datatype} \nWHERE ${conditions} RETURNING 1`
return query
}
case 'mysql': {