Fix APIv4 relationship_type_id join: use dot syntax not colon

This commit is contained in:
Joel Brock
2026-05-09 21:10:56 -07:00
parent da830af533
commit 1655c485d9
3 changed files with 8 additions and 8 deletions

View File

@@ -124,7 +124,7 @@ export async function GET(req: NextRequest) {
select: ["contact_id_b"],
where: [
["contact_id_a", "=", Number(cid)],
["relationship_type_id:name_a_b", "=", FORM_CONTACT_RELATIONSHIP],
["relationship_type_id.name_a_b", "=", FORM_CONTACT_RELATIONSHIP],
["is_active", "=", true],
],
limit: 2,

View File

@@ -295,16 +295,16 @@ async function probeContactRelationships(cid: string): Promise<CheckResult> {
id: number;
contact_id_a: number;
contact_id_b: number;
"relationship_type_id:name_a_b": string;
"relationship_type_id:name_b_a": string;
"relationship_type_id.name_a_b": string;
"relationship_type_id.name_b_a": string;
is_active: boolean;
}>("Relationship", "get", {
select: [
"id",
"contact_id_a",
"contact_id_b",
"relationship_type_id:name_a_b",
"relationship_type_id:name_b_a",
"relationship_type_id.name_a_b",
"relationship_type_id.name_b_a",
"is_active",
],
where: [
@@ -324,12 +324,12 @@ async function probeContactRelationships(cid: string): Promise<CheckResult> {
const lines = rows.map((r) => {
const sideA = String(r.contact_id_a) === cid ? "★A" : "·A";
const sideB = String(r.contact_id_b) === cid ? "★B" : "·B";
return ` ${sideA}=${r.contact_id_a} ${sideB}=${r.contact_id_b} type="${r["relationship_type_id:name_a_b"]}" / inverse="${r["relationship_type_id:name_b_a"]}"`;
return ` ${sideA}=${r.contact_id_a} ${sideB}=${r.contact_id_b} type="${r["relationship_type_id.name_a_b"]}" / inverse="${r["relationship_type_id.name_b_a"]}"`;
});
const usable = rows.find(
(r) =>
String(r.contact_id_a) === cid &&
r["relationship_type_id:name_a_b"] === FORM_CONTACT_RELATIONSHIP,
r["relationship_type_id.name_a_b"] === FORM_CONTACT_RELATIONSHIP,
);
return {
check: "contact_relationships_dump",

View File

@@ -54,7 +54,7 @@ export async function POST(req: Request) {
select: ["contact_id_b"],
where: [
["contact_id_a", "=", Number(cid)],
["relationship_type_id:name_a_b", "=", FORM_CONTACT_RELATIONSHIP],
["relationship_type_id.name_a_b", "=", FORM_CONTACT_RELATIONSHIP],
["is_active", "=", true],
],
limit: 2,