-
Notifications
You must be signed in to change notification settings - Fork 60
Closed
Description
First of all thank you for writing this lib
I follow the README on ecto_sqlite3 and I run into this error (Exqlite.Error) near "RETURNING": syntax error when I want to create record with Ecto.
sqlite3 version: SQLite version 3.35.3 2021-03-26 12:12:52
phoenix version: 1.5.8
mix phx.new my_app
mix phx.gen.html Accounts User users name:string age:integer
and modify the mix.exs with following
{:phoenix, "~> 1.5.8"},
{:phoenix_ecto, "~> 4.1"},
{:ecto_sqlite3, "~> 0.5.2"},
and run the mix ecto.create/mix ecto.migrate/mix compile without issues
> iex -S mix phx.server
> alias MyApp.Accounts.User
> alias MyApp.Repo
> attrs = %{name: "john", age: 18}
> %User{} |> User.changeset(attrs) |> Repo.insert
[debug] QUERY ERROR db=0.8ms idle=1918.2ms
INSERT INTO users (age,name,inserted_at,updated_at) VALUES (?,?,?,?) RETURNING id [18, "john", "2021-04-02T08:13:46", "2021-04-02T08:13:46"]
** (Exqlite.Error) near "RETURNING": syntax error
(ecto_sql 3.5.4) lib/ecto/adapters/sql.ex:751: Ecto.Adapters.SQL.raise_sql_call_error/1
(ecto 3.5.8) lib/ecto/repo/schema.ex:649: Ecto.Repo.Schema.apply/4
(ecto 3.5.8) lib/ecto/repo/schema.ex:262: anonymous fn/15 in Ecto.Repo.Schema.do_insert/4
and I hv no issue to query the db
Repo.all(User) # => []
I can see in the INSERT state got an extra RETURNING id that causing the exception.
Cheers
Follow up:
If I manually created a record first, then use the Ecto.update without issue
user = Accounts.get_user!(id)
attrs = %{age: 24}
user |> User.changeset(attrs) |> Repo.update
as the PR bump amalgamation to 3.35.0 (also the official docs )mention, the RETURNING is only for DELETE, INSERT, and UPDATE statements., not including CREATE
Metadata
Metadata
Assignees
Labels
No labels