Open rbarszcz opened 5 months ago
trying to make an update with dynamic columns and i'm getting a bunch of errors
object cliente: {
id: 3, nome: 'Teste Um', tipo: 'F', cpf: '12345678910', cnpj: null, email: 'teste@black.com', telefone: '46111111111', status: 'A', datacadastro: '2024-02-01'
}
query
const cols = ['nome', 'tipo', 'cpf', 'cnpj', 'email', 'telefone']; const update = await sql`UPDATE clientes SET (${sql(cliente, cols)}) WHERE id=${sql(cliente.id)}`;
error: Cannot convert undefined or null to object
query 2 (removed the null fields)
const cols = ['nome', 'tipo', 'cpf', 'email', 'telefone']; const update = await sql`UPDATE clientes SET (${sql(cliente, cols)}) WHERE id=${sql(cliente.id)}`;
error: syntax error at or near "$1"
query 3 (removed the () after SET)
const cols = ['nome', 'tipo', 'cpf', 'cnpj', 'email', 'telefone']; const update = await sql`UPDATE clientes SET ${sql(cliente, cols)} WHERE id=${sql(cliente.id)}`;
error: syntax error at end of input
any thoughts?
WHERE id=${sql(cliente.id)} to WHERE id=${cliente.id}
WHERE id=${sql(cliente.id)}
WHERE id=${cliente.id}
thanks.. damn, i feel stupid.. didn't see i wrapped it up with the sql()..
trying to make an update with dynamic columns and i'm getting a bunch of errors
object cliente: {
}
query
error: Cannot convert undefined or null to object
query 2 (removed the null fields)
error: syntax error at or near "$1"
query 3 (removed the () after SET)
error: syntax error at end of input
any thoughts?