Drizzle TeamDT
Drizzle Team14mo ago
1 reply
tazmaniax

Unable to pass JSON array to PostgreSQL function jsonb[] parameter using execute raw SQL

When I run the following query I get the error PostgresError: malformed array literal: "[{"data":"test batch message 1"},{"data":"test batch message 2"}]
    const msgs = [
      { data: "test batch message 1" },
      { data: "test batch message 2" },
    ]
    const result = await this.db.execute<{ send_batch: number }>(
      sql`SELECT * FROM pgmq.send_batch(${this.queueName}, ${JSON.stringify(msgs)}::jsonb[], ${delay})`,
    )
Was this page helpful?