ppx_rapper icon indicating copy to clipboard operation
ppx_rapper copied to clipboard

INSERT has more expressions than target columns using list of strings

Open AdamBrodzinski opened this issue 10 months ago • 0 comments

Hello,

I'm running into issues with the ppx generating an extra input param when using the nested list of strings. I'm not sure if this is a bug or I'm misinterpreting the docs?

Given this query:

  type t = {
    chords : string list;
  }
  [@@deriving make,show]


  let query = [%rapper get_one {sql| 
    insert into videos (
      chords
    )
    VALUES (
      %list{%string{chords}}
    )
    returning @string{id}
  |sql} record_in]

and when I run it with the input {chords = ["one"; "two"]} (with Postgres) I get the error:

REQ 1 Database error: Request to <postgresql://localhost/dev> failed: 
ERROR:  INSERT has more expressions than target columns
LINE 6:       $1, $2
                  ^
 Query: " 
    insert into videos (
      chords
    )
    VALUES (
      $1, $2
    )
    returning id
  ".

opam lock:

  "caqti" {= "1.9.0"}
  "caqti-driver-postgresql" {= "1.9.1"}
  "caqti-lwt" {= "1.9.0"}
  "ppx_rapper" {= "3.1.0"}
  "ppx_rapper_lwt" {= "3.1.0"}
  "pg_query" {= "0.9.7"}
  "postgresql" {= "5.0.0"}  

AdamBrodzinski avatar Apr 20 '24 19:04 AdamBrodzinski