Skip to content

Conversation

@dmythro
Copy link

@dmythro dmythro commented Sep 3, 2025

The simplest way I found to allow self-relations securely (avoiding infinite depth etc), without breaking anything else or introducing extra configuration.

Issue: #38

Copilot AI review requested due to automatic review settings September 3, 2025 16:09
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for self-relations (tables referencing themselves) when a relationsDepthLimit is configured. Previously, self-relations were blocked by the usedTables check regardless of depth limit settings.

  • Modified the condition in generateSelectFields to allow self-relations when relationsDepthLimit is set
  • Added parentId column to Posts table schema for self-referencing functionality
  • Added comprehensive tests covering both default behavior (blocking self-relations) and new behavior (allowing self-relations with depth limits)

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/util/builders/common.ts Updated logic to conditionally apply usedTables check based on relationsDepthLimit setting
tests/schema/pg.ts Added parentId column and parent/replies relations for self-referencing Posts
tests/pg.test.ts Added extensive test coverage for self-relation behavior with and without depth limits

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

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