Skip to content

Using placeholders results in (Exqlite.Error) expected 6 arguments, got 5 #152

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

Closed
axelson opened this issue Oct 26, 2024 · 5 comments · Fixed by #154
Closed

Using placeholders results in (Exqlite.Error) expected 6 arguments, got 5 #152

axelson opened this issue Oct 26, 2024 · 5 comments · Fixed by #154
Assignees
Labels
bug Something isn't working

Comments

@axelson
Copy link

axelson commented Oct 26, 2024

Using ecto's placeholder feature results in an unexpected error:

placeholders = %{timestamp: ~N[2024-10-26 16:40:06]}

attrs = [
  %{
    id: 12911,
    json: %{a: 42},
    author_login: "jason",
    committed_date: ~N[2024-10-25 17:57:25],

    # Inserting with placeholders results in `(Exqlite.Error) expected 6 arguments, got 5`
    inserted_at: {:placeholder, :timestamp},
    updated_at: {:placeholder, :timestamp},

    # Inserting directly successfully inserts the row
    # inserted_at: placeholders.timestamp,
    # updated_at: placeholders.timestamp,
  }
]

Sqlite3Repro.Repo.insert_all(
  Sqlite3Repro.MergedPullRequest,
  attrs,
  placeholders: placeholders
)

Results in:

iex(1)> Sqlite3Repro.run_and_save_merged_prs_query
** (Exqlite.Error) expected 6 arguments, got 5
INSERT INTO "merged_pull_requests" ("id","json","author_login","committed_date","inserted_at","updated_at") VALUES (?,?,?,?,?,?)
(ecto_sql 3.12.1) lib/ecto/adapters/sql.ex:1096: Ecto.Adapters.SQL.raise_sql_call_error/1
(ecto_sql 3.12.1) lib/ecto/adapters/sql.ex:967: Ecto.Adapters.SQL.insert_all/9
(ecto 3.12.4) lib/ecto/repo/schema.ex:59: Ecto.Repo.Schema.do_insert_all/7
(sqlite3_repro 0.1.0) lib/sqlite3_repro.ex:60: Sqlite3Repro.run_and_save_merged_prs_query/0
iex:1: (file)

Full repro is at https://github.com/axelson/sqlite3_repro

@warmwaffles
Copy link
Member

I don't think I implemented placeholders 😞

@warmwaffles warmwaffles self-assigned this Oct 28, 2024
@warmwaffles warmwaffles added the bug Something isn't working label Oct 28, 2024
@warmwaffles
Copy link
Member

@axelson I have a fix to support {:placeholder, :placeholderkey} the problem is I'm now getting a ** (Exqlite.Error) datatype mismatch. Working through that now.

warmwaffles added a commit that referenced this issue Oct 28, 2024
I went ahead and added in support for cell-wise support for bounded
values. This has been on the todo list for a while.

fixes: #152
warmwaffles added a commit that referenced this issue Oct 28, 2024
I went ahead and added in support for cell-wise support for bounded
values. This has been on the todo list for a while.

fixes: #152
@warmwaffles
Copy link
Member

@axelson published under v0.17.3

@axelson
Copy link
Author

axelson commented Oct 28, 2024

@warmwaffles wow, that was fast! Thank you so much! I just tested it in my full app and it's now working! 🎉

@warmwaffles
Copy link
Member

No problem. I was meaning to implement cell wise placeholders. This is just the excuse I needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants