Skip to content

fix(codegen): use resolved entity name for manyToMany rightTable instead of re-singularizing#934

Merged
pyramation merged 2 commits intomainfrom
devin/1774847515-fix-m2m-singularize-codegen
Mar 30, 2026
Merged

fix(codegen): use resolved entity name for manyToMany rightTable instead of re-singularizing#934
pyramation merged 2 commits intomainfrom
devin/1774847515-fix-m2m-singularize-codegen

Conversation

@pyramation
Copy link
Copy Markdown
Contributor

Summary

Fixes a bug where manyToMany rightTable values in the inferred table metadata used incorrect inflections (e.g. Codebasis instead of Codebase), causing type errors in generated SDKs.

The inferHasManyOrManyToMany function was extracting the entity name from the GraphQL field name prefix via regex, then re-singularizing it with inflekt. For irregular plurals like codebases, singularize("Codebases") produced "Codebasis" instead of "Codebase".

The fix: use relatedEntityName, which is already correctly resolved from the connectionToEntity map (derived from the connection type's nodes field) earlier in the same function. This is the same resolution path already used for hasMany relations.

Review & Testing Checklist for Human

  • Verify there is no edge case where the connection type doesn't appear in connectionToEntity but the field-name prefix regex would have produced the correct entity name. The fallback on line 532-537 still calls singularize, so unresolved connection types would still get wrong inflections — confirm this is acceptable.
  • Consider whether a regression test for an irregular plural (e.g. codebasesByXxxAndYyyCodebase not Codebasis) should be added to infer-tables.test.ts.
  • After merging, re-run the agentic-db export pipeline to confirm the generated SDK no longer contains Codebasis type references.

Notes

  • All 312 existing codegen tests pass, including the manyToMany test asserting rightTable === 'Product'.
  • The existing test uses a regular plural (productsProduct) so it didn't catch this bug. The bug only manifests with words where singularize produces an incorrect result (like codebasesCodebasis).

Link to Devin session: https://app.devin.ai/sessions/6dd1a19fd02948fda1fee04c955f4bf2
Requested by: @pyramation

…ead of re-singularizing

The inferHasManyOrManyToMany function was extracting the entity name from
the field name prefix and re-singularizing it, which produced incorrect
inflections for some words (e.g. 'codebases' → 'Codebasis' instead of
'Codebase'). The related entity name was already correctly resolved from
the connectionToEntity map, so we use that directly instead.
@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

…taSearch embedding params

The data_embedding SQL trigger already supports a 'chunks' passthrough config
that inserts into metaschema_public.embedding_chunks when present. This adds the
corresponding TypeScript type definitions so consumers (e.g. agentic-db provision)
can use chunks: {} in blueprint DataSearch/DataEmbedding node configs without
TypeScript errors.

Properties match the embedding_chunks table columns:
- content_field_name, chunk_size, chunk_overlap, chunk_strategy
- metadata_fields, enqueue_chunking_job, chunking_task_name
@pyramation pyramation merged commit e6b62fa into main Mar 30, 2026
43 checks passed
@pyramation pyramation deleted the devin/1774847515-fix-m2m-singularize-codegen branch March 30, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant