eng-1344 f10b upload obsidian relations and their schemas#721
eng-1344 f10b upload obsidian relations and their schemas#721
Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
6bfab2f to
408ef40
Compare
f966a5b to
7f0a45d
Compare
5fdb70d to
0b3d0cb
Compare
3d49688 to
3b0a73a
Compare
3fb53ae to
f661f0f
Compare
3b0a73a to
6c48b9f
Compare
f661f0f to
df19c3c
Compare
ea45b20 to
9e74420
Compare
9e74420 to
63c0832
Compare
63c0832 to
982652f
Compare
#722) * eng-1344 f10b upload obsidian relations and their schemas * current progress * feature finished * address PR comments * address PR comments * remove local test file * curr progress * revert what is handled in #721 * Use SpaceURI rather than spaceId in frontmatter * address PR comments * address PR comments * cleanup * Update apps/obsidian/src/utils/importNodes.ts Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> * normalize on using numbers for dates * correction * apply ctime, mtime to assets * spurious log * Preserve ctime, mtime in processFrontMatter. Also timezone correction * add lastModified in frontMatter * make sure import image works * add recursive folder creation * modify the fetchNodeContent flow; simplify the pathMapping * WIP: shuffle the filePath around * send originalPathDepth * actually send path itself * clarify var name * make sure fileImport works for all possible settings * store relative path when rewrite the wikilink instead of default to fileToLinkText * cleanup logs * nit * AI corrections * Update apps/obsidian/src/utils/importNodes.ts Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> * address PR comments --------- Co-authored-by: Marc-Antoine Parent <maparent@acm.org> Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
e82b16b to
376b1a4
Compare
| relationType; | ||
| return { | ||
| space_id: context.spaceId, | ||
| name: label, |
There was a problem hiding this comment.
🔴 discourseRelationTypeToLocalConcept uses non-unique label as concept name, causing upsert failure and cascading errors
The new discourseRelationTypeToLocalConcept function sets name: label where label is the user-facing display label of a relation type (e.g., "Supports", "Opposes"). This can collide with the unique constraint concept_space_and_name_idx on (space_id, name) in the database.
Root Cause and Cascading Failure
The database enforces CREATE UNIQUE INDEX concept_space_and_name_idx ON public."Concept" (space_id, name); (packages/database/supabase/schemas/concept.sql:87). Node type schemas are created with name: name (the node type's name) in discourseNodeSchemaToLocalConcept (apps/obsidian/src/utils/conceptConversion.ts:47). The new relation type concepts use name: label at line 77.
If a relation type's label matches any node type's name (e.g., both named "Evidence"), or if two relation types share the same label, only one concept can be inserted. The SQL upsert_concepts function handles this with RETURN NEXT -1 (packages/database/supabase/schemas/concept.sql:379), so the relation type concept silently fails to insert.
The real problem is cascading: discourseRelationSchemaToLocalConcept at line 127 puts relation_type: relationshipTypeId in local_reference_content. When the SQL function _local_concept_to_db_concept processes this, it does SELECT cpt.id INTO STRICT ref_single_val FROM public."Concept" AS cpt WHERE cpt.source_local_id = ... (packages/database/supabase/schemas/concept.sql:316-318). Since the relation type concept was never inserted (due to the name collision), INTO STRICT throws an unhandled exception, aborting the entire upsert_concepts call and failing all remaining concepts in the batch.
Impact: Any name collision between a relation type label and a node type name (or between two relation type labels) causes the entire concept sync to fail, preventing all node and relation data from being uploaded to Supabase.
The Roam version avoids this by using name: getPageTitleByPageUid(relation.id) (apps/roam/src/utils/conceptConversion.ts:125), which yields a unique identifier.
| name: label, | |
| name: `${id}-${label}`, |
Was this helpful? React with 👍 or 👎 to provide feedback.
d406e78 to
0f8912b
Compare
0f8912b to
13b342e
Compare
This uploads relationship schemas to supabase.