Inserting with Repo.insert()
I get this error:
[debug] QUERY ERROR db=45.5ms queue=5.9ms
INSERT INTO `movies` (`id_nf`,`title`,`year`,`inserted_at`,`updated_at`) VALUES (?,?,?,?,?) [6483, <<83, 109, 111, 107, 101, 121, 32, 74, 111, 101, 39, 115, 32, 67, 97, 102, 233>>, 2001, ~N[2019-08-01 10:52:13], ~N[2019-08-01 10:52:13]]
** (MyXQL.Error) (1406) (ER_DATA_TOO_LONG) Data too long for column 'title' at row 1
(ecto_sql) lib/ecto/adapters/myxql.ex:208: Ecto.Adapters.MyXQL.insert/6
(ecto) lib/ecto/repo/schema.ex:649: Ecto.Repo.Schema.apply/4
(ecto) lib/ecto/repo/schema.ex:262: anonymous fn/15 in Ecto.Repo.Schema.do_insert/4
(mvsg_ex) lib/scripts.ex:31: anonymous fn/2 in Mvsg.Scripts.load_nf/0
(elixir) lib/enum.ex:783: Enum."-each/2-lists^foreach/1-0-"/2
(elixir) lib/enum.ex:783: Enum.each/2
(mvsg_ex) lib/scripts.ex:27: Mvsg.Scripts.load_nf/0
iex(3)> IO.puts [83, 109, 111, 107, 101, 121, 32, 74, 111, 101, 39, 115, 32, 67, 97, 102, 233]
Smokey Joe's Café
Which sounds like it is saying the text for the title (“Smokey Joe’s Café”) is too long, but the field is VARCHAR(255) so it should fit. In fact I am able to insert it with the following pure SQL query:
INSERT INTO `movies` (`id_nf`,`title`,`year`,`inserted_at`,`updated_at`) VALUES (6483, "Smokey Joe's Café", 2001, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
(Copied and edited from the error message)
Is this a bug? What can I do other than inserting with raw sql when this happens?