Using Ecto.insert_all with abstract schema

I have an abstract schema that looks like this:

@schema_prefix "someprefix"
  schema "abstract table: my_schema" do

    field(:field1, :string)
    field(:field2, :string)
    field(:field3, :string)

I’m trying to use insert_all to insert rows into this table like so:

Repo.insert_all({table_name, MySchema}, entries)

When I do this, I get the following error:

** (ArgumentError) unknown field `field1` in schema MyApp.MySchema given to insert_all. Note virtual fields and associations are not supported
        (ecto) lib/ecto/repo/schema.ex:115: anonymous fn/5 in Ecto.Repo.Schema.init_mapper/3

Am I doing something wrong? Or are abstract tables just not supported by insert_all?

Just use the table name alone. *_all functions on repo are all very low level.

1 Like