Dyey517
Dyey517

Reputation: 586

How to store two dimension array of string in Elixir Ecto. How to put matching length to list?

How do I save 2d lists into postgres? Or put matching lengths to lists?

I tried this in my migration..

  add :checkpoints, {:array, :string}

and schema..

  field :checkpoints, {:array, {:array, :string}}

But when i save this sample value of [["C23", "E12"], ["N34"], ["G22"]] to :checkpoints field, I get this error:

(ArgumentError) nested lists must have lists with matching lengths

Upvotes: 1

Views: 514

Answers (1)

Marcos Tapajós
Marcos Tapajós

Reputation: 564

All of our lists need to have the same length. Your first list has three elements, the other ones have only 1.

Upvotes: 5

Related Questions