Created
November 2, 2019 20:01
-
-
Save mazz/5d7f957c1eae8a7705ff3d787dd3856a to your computer and use it in GitHub Desktop.
field `taskcategories` in `select` is a virtual field in schema Db.Schema.Task in query:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query = | |
from(task in Task, | |
join: org in Org, | |
join: rubric in Rubric, | |
join: coursecode in CourseCode, | |
join: task_category in TaskCategory, | |
where: org.uuid == ^org_uuid, | |
where: org.id == task.org_id, | |
where: rubric.id == task.rubric_id, | |
where: coursecode.id == task.coursecode_id, | |
where: task_category.task_id == task.id, | |
preload: [taskcategories: :taskitems], | |
select: %{ | |
title: task.task_title, | |
uuid: task.uuid, | |
org_uuid: org.uuid, | |
archived: task.archived, | |
course_task_type: task.course_task_type, | |
task_id: task.id, | |
rubric: rubric, | |
coursecode: coursecode, | |
task_category: task.taskcategories, | |
inserted_at: task.inserted_at, | |
updated_at: task.updated_at, | |
hash_id: task.hash_id | |
} | |
) |
error:
[error] #PID<0.803.0> running MarkablyApi.Endpoint (connection #PID<0.802.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: GET /v1.0/orgs/a7d22995-7e6f-47a6-b724-5b646a552799/tasks?offset=1&limit=50
** (exit) an exception was raised:
** (Ecto.QueryError) apps/markably_api/lib/markably_api/controllers/api/v1.0/v10.ex:290: field `taskcategories` in `select` is a virtual field in schema Db.Schema.Task in query:
from t0 in Db.Schema.Task,
join: o1 in Db.Schema.Org,
on: true,
join: r2 in Db.Schema.Rubric,
on: true,
join: c3 in Db.Schema.CourseCode,
on: true,
join: t4 in Db.Schema.TaskCategory,
on: true,
where: o1.uuid == ^<<167, 210, 41, 149, 126, 111, 71, 166, 183, 36, 91, 100, 106, 85, 39, 153>>,
where: o1.id == t0.org_id,
where: r2.id == t0.rubric_id,
where: c3.id == t0.coursecode_id,
where: t4.task_id == t0.id,
limit: ^50,
offset: ^0,
select: %{title: t0.task_title, uuid: t0.uuid, org_uuid: o1.uuid, archived: t0.archived, course_task_type: t0.course_task_type, task_id: t0.id, rubric: r2, coursecode: c3, task_category: t0.taskcategories, inserted_at: t0.inserted_at, updated_at: t0.updated_at, hash_id: t0.hash_id},
preload: [{:taskcategories, [:taskitems]}, :taskcategories]
(elixir) lib/enum.ex:1440: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
(elixir) lib/enum.ex:1440: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
(elixir) lib/enum.ex:1948: Enum."-reduce/3-lists^foldl/2-0-"/3
(ecto) lib/ecto/repo/queryable.ex:161: Ecto.Repo.Queryable.execute/4
(ecto) lib/ecto/repo/queryable.ex:17: Ecto.Repo.Queryable.all/3
(scrivener_ecto) lib/scrivener/paginater/ecto/query.ex:28: Scrivener.Paginater.Ecto.Query.paginate/2
(markably_api) lib/markably_api/controllers/api/org_controller.ex:65: MarkablyApi.OrgController.tasksv10/2
(markably_api) lib/markably_api/controllers/api/org_controller.ex:1: MarkablyApi.OrgController.action/2
(markably_api) lib/markably_api/controllers/api/org_controller.ex:1: MarkablyApi.OrgController.phoenix_controller_pipeline/2
(phoenix) lib/phoenix/router.ex:288: Phoenix.Router.__call__/2
fixed:
def tasks_by_org_uuid(orguuid, offset, limit) do
{:ok, org_uuid} = Ecto.UUID.dump(orguuid)
query =
from(task in Task,
join: org in Org,
join: rubric in Rubric,
join: coursecode in CourseCode,
where: org.uuid == ^org_uuid,
where: org.id == task.org_id,
where: rubric.id == task.rubric_id,
where: coursecode.id == task.coursecode_id,
preload: [:taskcategories, taskcategories: :taskitems],
select: %{task: task, coursecode: coursecode, rubric: rubric, org: org}
)
query
|> Repo.paginate(page: offset, page_size: limit)
end
What was the issue?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
also tried:
preload: [:taskcategories, taskcategories: :taskitems],
Task.ex:
TaskCategory.ex:
TaskItem.ex