postgres icon indicating copy to clipboard operation
postgres copied to clipboard

INSERT multiple sets optional boolean values to all null if first element is null

Open alicia-pika opened this issue 9 months ago • 0 comments

const equipmentList = 
[{
    someKey: "value1",
    optionalBool: null
  },
  {
    someKey: "value2",
    optionalBool: true
  },
  {
    someKey: "value3",
    optionalBool: false
  }]

await sql`insert into equipment ${sql(listOfThings)}` 

Because we used implicit columns and the first element has a null value, the resulting db table winds up with all optionalBool values as null. If the first element has a boolean for optionalBool, the column is saved correctly.

Version 3.4.3

We've worked around it but thought I should report it.

alicia-pika avatar Jan 21 '25 19:01 alicia-pika