feat: Improve error message for ambiguous embedding

- Adds a relevant hint that includes unambiguous embedding suggestions.
- Joins origin and target into one single embedding key
This commit is contained in:
Laurence Isla
2021-11-23 22:23:29 -05:00
committed by GitHub
parent 1b48531369
commit 62243852b6
3 changed files with 58 additions and 60 deletions
+30 -41
View File
@@ -19,20 +19,18 @@ spec =
{
"details": [
{
"cardinality": "m2o",
"cardinality": "many-to-one",
"relationship": "message_sender_fkey[sender][id]",
"origin": "test.message",
"target": "test.person"
"embedding": "message with person"
},
{
"cardinality": "m2o",
"cardinality": "many-to-one",
"relationship": "message_sender_fkey[sender][id]",
"origin": "test.message",
"target": "test.person_detail"
"embedding": "message with person_detail"
}
],
"hint": "By following the 'details' key, disambiguate the request by changing the url to /origin?select=relationship(*) or /origin?select=target!relationship(*)",
"message": "More than one relationship was found for message and sender"
"hint": "Try changing 'sender' to one of the following: 'person!message_sender_fkey', 'person_detail!message_sender_fkey'. Find the desired relationship in the 'details' key.",
"message": "Could not embed because more than one relationship was found for 'message' and 'sender'"
}
|]
{ matchStatus = 300
@@ -45,26 +43,23 @@ spec =
{
"details": [
{
"cardinality": "m2o",
"cardinality": "many-to-one",
"relationship": "main_project[main_project_id][big_project_id]",
"origin": "test.sites",
"target": "test.big_projects"
"embedding": "sites with big_projects"
},
{
"cardinality": "m2m",
"cardinality": "many-to-many",
"relationship": "test.jobs[jobs_site_id_fkey][jobs_big_project_id_fkey]",
"origin": "test.sites",
"target": "test.big_projects"
"embedding": "sites with big_projects"
},
{
"cardinality": "m2m",
"cardinality": "many-to-many",
"relationship": "test.main_jobs[jobs_site_id_fkey][jobs_big_project_id_fkey]",
"origin": "test.sites",
"target": "test.big_projects"
"embedding": "sites with big_projects"
}
],
"hint": "By following the 'details' key, disambiguate the request by changing the url to /origin?select=relationship(*) or /origin?select=target!relationship(*)",
"message": "More than one relationship was found for sites and big_projects"
"hint": "Try changing 'big_projects' to one of the following: 'big_projects!main_project', 'big_projects!jobs', 'big_projects!main_jobs'. Find the desired relationship in the 'details' key.",
"message": "Could not embed because more than one relationship was found for 'sites' and 'big_projects'"
}
|]
{ matchStatus = 300
@@ -77,20 +72,18 @@ spec =
{
"details": [
{
"cardinality": "m2o",
"cardinality": "many-to-one",
"relationship": "agents_department_id_fkey[department_id][id]",
"origin": "test.agents",
"target": "test.departments"
"embedding": "agents with departments"
},
{
"cardinality": "o2m",
"cardinality": "one-to-many",
"relationship": "departments_head_id_fkey[id][head_id]",
"origin": "test.agents",
"target": "test.departments"
"embedding": "agents with departments"
}
],
"hint": "By following the 'details' key, disambiguate the request by changing the url to /origin?select=relationship(*) or /origin?select=target!relationship(*)",
"message": "More than one relationship was found for agents and departments"
"hint": "Try changing 'departments' to one of the following: 'departments!agents_department_id_fkey', 'departments!departments_head_id_fkey'. Find the desired relationship in the 'details' key.",
"message": "Could not embed because more than one relationship was found for 'agents' and 'departments'"
}
|]
{ matchStatus = 300
@@ -106,32 +99,28 @@ spec =
{
"details": [
{
"cardinality": "m2m",
"cardinality": "many-to-many",
"relationship": "test.whatev_jobs[whatev_jobs_site_id_1_fkey][whatev_jobs_project_id_1_fkey]",
"origin": "test.whatev_sites",
"target": "test.whatev_projects"
"embedding": "whatev_sites with whatev_projects"
},
{
"cardinality": "m2m",
"cardinality": "many-to-many",
"relationship": "test.whatev_jobs[whatev_jobs_site_id_1_fkey][whatev_jobs_project_id_2_fkey]",
"origin": "test.whatev_sites",
"target": "test.whatev_projects"
"embedding": "whatev_sites with whatev_projects"
},
{
"cardinality": "m2m",
"cardinality": "many-to-many",
"relationship": "test.whatev_jobs[whatev_jobs_site_id_2_fkey][whatev_jobs_project_id_1_fkey]",
"origin": "test.whatev_sites",
"target": "test.whatev_projects"
"embedding": "whatev_sites with whatev_projects"
},
{
"cardinality": "m2m",
"cardinality": "many-to-many",
"relationship": "test.whatev_jobs[whatev_jobs_site_id_2_fkey][whatev_jobs_project_id_2_fkey]",
"origin": "test.whatev_sites",
"target": "test.whatev_projects"
"embedding": "whatev_sites with whatev_projects"
}
],
"hint": "By following the 'details' key, disambiguate the request by changing the url to /origin?select=relationship(*) or /origin?select=target!relationship(*)",
"message": "More than one relationship was found for whatev_sites and whatev_projects"
"hint": "Try changing 'whatev_projects' to one of the following: 'whatev_projects!whatev_jobs', 'whatev_projects!whatev_jobs', 'whatev_projects!whatev_jobs', 'whatev_projects!whatev_jobs'. Find the desired relationship in the 'details' key.",
"message": "Could not embed because more than one relationship was found for 'whatev_sites' and 'whatev_projects'"
}
|]
{ matchStatus = 300