Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INSERT has more expressions than target columns using list of strings #44

Open
AdamBrodzinski opened this issue Apr 20, 2024 · 0 comments

Comments

@AdamBrodzinski
Copy link

AdamBrodzinski commented Apr 20, 2024

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"}  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant