Effect CommunityEC
Effect Community2y ago
4 replies
Steff

Issue with `sqlfx/pg` array insertion: `params` only contains the first element of the array

I'm trying to insert an array with sqlfx/pg, and to test out the query, I'm wondering why params does only contain the first element of the array (categories)?
const [query, params] = sql`INSERT INTO people ${sql.insert({
      name: "Tim",
      age: 10,
      categories: sql.array(["Category 1", "Category 2"]),
    })}`.compile();

    console.log("query", query); //query INSERT INTO people ("name","age","categories") VALUES ($1,$2,$3)
    console.log("params", params); //params [ 'Tim', 10, 'Category 1' ]
Was this page helpful?