Skip to content

[schemas] Fix invalid || concatenation in typed-reasoning-edges COMMENT#227

Open
spiritualsystems wants to merge 1 commit intoNateBJones-Projects:mainfrom
spiritualsystems:contrib/spiritualsystems/fix-typed-edges-comment-syntax
Open

[schemas] Fix invalid || concatenation in typed-reasoning-edges COMMENT#227
spiritualsystems wants to merge 1 commit intoNateBJones-Projects:mainfrom
spiritualsystems:contrib/spiritualsystems/fix-typed-edges-comment-syntax

Conversation

@spiritualsystems
Copy link
Copy Markdown

Contribution Type

  • Schema (/schemas)
  • Recipe (/recipes)
  • Dashboard (/dashboards)
  • Integration (/integrations)
  • Skill (/skills)
  • Repo improvement (docs, CI, templates)

What does this do?

Fixes a SQL syntax error in schemas/typed-reasoning-edges/schema.sql (introduced in #208) that prevents the migration from applying. The COMMENT ON FUNCTION public.thought_edges_upsert IS ... statement uses || string concatenation across three adjacent string literals, but PostgreSQL requires the right-hand side of COMMENT ON ... IS to be a single string literal — not an expression. Flattens the three pieces into one literal. No functional change to the function itself.

Bug

At schemas/typed-reasoning-edges/schema.sql#L257-L260:

COMMENT ON FUNCTION public.thought_edges_upsert IS
  'Insert or (on duplicate key) bump support_count + refresh temporal bounds. ' ||
  'Call via POST /rpc/thought_edges_upsert. Use instead of a plain INSERT when ' ||
  'you want repeated classifications of the same pair to accumulate evidence.';

Per the Postgres grammar for COMMENT, IS takes a text literal, not a general expression — concatenation operators aren't parsed here. None of the other COMMENT ON sites in this file have the issue; this is the only affected statement.

Reproduce

From a clean Supabase project with the rest of Open Brain applied:

# Stage this schema as a migration and push
supabase db push

Result on main:

ERROR: syntax error at or near "||" (SQLSTATE 42601)
At statement: 31
  COMMENT ON FUNCTION public.thought_edges_upsert IS
    'Insert or (on duplicate key) bump support_count + refresh temporal bounds. ' ||
    ...

The transaction rolls back and none of the typed-reasoning-edges objects (thought_edges table, thought_edges_upsert RPC, entity-edge temporal columns) get created.

Fix

Collapse the three concatenated literals into one. The surrounding code is untouched; other COMMENT ON lines in the file are not reformatted.

COMMENT ON FUNCTION public.thought_edges_upsert IS
  'Insert or (on duplicate key) bump support_count + refresh temporal bounds. Call via POST /rpc/thought_edges_upsert. Use instead of a plain INSERT when you want repeated classifications of the same pair to accumulate evidence.';

Requirements

None beyond what #208 already requires (Supabase with pgvector). No new dependencies.

Checklist

  • I've read CONTRIBUTING.md
  • Applied the patched schema via supabase db push on my own Open Brain instance — migration now completes without rollback
  • No credentials, API keys, or secrets are included
  • Change is scoped to the one broken statement (no reformatting, no other COMMENT ON lines touched)
  • N/A — not a new contribution (bug fix to existing schemas/typed-reasoning-edges/), so no new README.md / metadata.json required

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

PostgreSQL does not accept `||` string concatenation inside a
`COMMENT ON ... IS <literal>` expression; the RHS must be a single
string literal. As written, `supabase db push` fails with
SQLSTATE 42601 (syntax error at or near "||") and rolls back the
whole migration. Flatten the three concatenated strings into one.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the schema Contribution: database extension label Apr 23, 2026
@github-actions
Copy link
Copy Markdown

Hey @spiritualsystems — welcome to Open Brain Source! 👋

Thanks for submitting your first PR. The automated review will run shortly and check things like metadata, folder structure, and README completeness. If anything needs fixing, the review comment will tell you exactly what.

Once the automated checks pass, a human admin will review for quality and clarity. Expect a response within a few days.

If you have questions, check out CONTRIBUTING.md or open an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

schema Contribution: database extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant