我正在使用Ecto 2.0.0-rc.4我已经完成了这个无效的查询
def users do
Repo.all(
from u in User,
where: u.id == "93fd15fb-fe21-4a59-813d-f80447417a23",
select: u
)
end
id是数据库中的一个,它显示的错误是
** (Postgrex.Error) ERROR (character_not_in_repertoire): invalid byte sequence for encoding "UTF8": 0x93
[debug] QUERY ERROR db=8.2ms queue=0.2ms
SELECT u0."id", u0."full_name", u0."email", u0."encrypted_password", u0."settings", u0."organizations", u0."inserted_at", u0."updated_at" FROM "users" AS u0 WHERE (u0."id" = '��^U��!JY�=�^DGAz#') []
(ecto) lib/ecto/adapters/sql.ex:395: Ecto.Adapters.SQL.execute_and_cache/7
(ecto) lib/ecto/repo/queryable.ex:127: Ecto.Repo.Queryable.execute/5
(ecto) lib/ecto/repo/queryable.ex:40: Ecto.Repo.Queryable.all/4
还尝试将{:ok,id} = Ecto.UUID.dump“93fd15fb-fe21-4a59-813d-f80447417a23”转换为bitstring和query u.id == ^id
但不起作用 -
这是和Ecto问题。
答案 0 :(得分:0)
这是我的错;只需要将以下导入添加到我的模型中(即:import Ecto.Query
):
def all(org_id) do
Repo.all(
from l in Ledger,
where: l.organization_id == ^org_id
)
end