如何使用 UUID 查询 Ecto 2.0

How to query Ecto 2.0 with UUID

我正在使用 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" 转换为位串和 query u.id == ^id 但没有成功-

这是和Ecto的问题吗

这是我的错误;只需要将以下导入添加到我的模型中(即:import Ecto.Query):

  def all(org_id) do
    Repo.all(
      from l in Ledger,
      where: l.organization_id == ^org_id
    )
  end