Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 5, 2026

Why make this change?

Closes #3071

GraphQL queries with M:N relationships fail with SQL error 208 ("Invalid object name") when the linking object uses a custom schema (e.g., "linkingObject": "mySchema.books_authors"). The query works only if a table with the same name exists in dbo.

What is this change?

DatabaseObject.Equals() and GetHashCode() used case-sensitive string comparison. SQL Server schema/table names are case-insensitive, causing FK definition lookups to fail when database-returned names differ in casing from config-specified names.

  • DatabaseObject.cs: Use StringComparison.OrdinalIgnoreCase for Equals() and ToUpperInvariant() for GetHashCode()
public bool Equals(DatabaseObject? other)
{
    return other is not null &&
           string.Equals(SchemaName, other.SchemaName, StringComparison.OrdinalIgnoreCase) &&
           string.Equals(Name, other.Name, StringComparison.OrdinalIgnoreCase);
}

How was this tested?

  • Integration Tests
  • Unit Tests

Added TestRelationshipWithLinkingObjectInCustomSchema with test cases for:

  • Custom schema linking object (mySchema.TEST_SOURCE_LINK)
  • Uppercase schema (MYSCHEMA.TEST_SOURCE_LINK)
  • Lowercase schema and table (myschema.test_source_link)

Sample Request(s)

query {
  authors {
    items {
      id
      books {
        items {
          title
        }
      }
    }
  }
}

With config:

"authors": {
  "relationships": {
    "books": {
      "cardinality": "many",
      "target.entity": "books",
      "linking.object": "mySchema.books_authors",
      "linking.source.fields": ["author_id"],
      "linking.target.fields": ["book_id"]
    }
  }
}
Original prompt

work on the github issue #3071


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

)

Co-authored-by: Alekhya-Polavarapu <67075378+Alekhya-Polavarapu@users.noreply.github.com>
Copilot AI changed the title [WIP] Address GitHub issue #3071 Fix many-to-many relationship queries with custom schema linking objects Feb 5, 2026
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.

[Bug]: GraphQL queries fail with many-to-many relationships on custom schema

2 participants