Skip to content
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

Update insert_all docs to say entries can contain string keys #4416

Merged
merged 2 commits into from
May 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions lib/ecto/repo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1427,9 +1427,11 @@ defmodule Ecto.Repo do
both (`{"users", MyApp.User}`) as the first argument. The second
argument is a list of entries to be inserted, either as keyword
lists or as maps. The keys of the entries are the field names as
atoms and the value should be the respective value for the field
type or, optionally, an `Ecto.Query` that returns a single entry
with a single value.
atoms, when a schema module is specified in the first argument.
Otherwise, the keys can be either atoms or strings representing
the names of the columns in the underlying datastore. The value
should be the respective value for the field type or, optionally,
an `Ecto.Query` that returns a single entry with a single value.

It returns a tuple containing the number of entries
and any returned result as second element. If the database
Expand Down Expand Up @@ -1587,11 +1589,11 @@ defmodule Ecto.Repo do
"""
@doc group: "Schema API"
@callback insert_all(
schema_or_source :: binary | {binary, module} | module,
entries_or_query :: [%{atom => value} | Keyword.t(value)] | Ecto.Query.t(),
schema_or_source :: binary() | {binary(), module()} | module(),
entries_or_query :: [%{(atom() | String.t()) => value} | Keyword.t(value)] | Ecto.Query.t(),
opts :: Keyword.t()
) :: {non_neg_integer, nil | [term]}
when value: term | Ecto.Query.t()
) :: {non_neg_integer(), nil | [term()]}
when value: term() | Ecto.Query.t()

@doc """
Inserts a struct defined via `Ecto.Schema` or a changeset.
Expand Down
Loading