Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

MJoin with inner LeftJoin, does not put LeftJoin at end.

Open
#15 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp, sql
Domain
backend, databases

Research direction

Start at the MJoin and LeftJoin entry points and trace how their joins are assembled into the generated SQL shown in the issue. Verify the ordering with an equivalent example: the inner joins should be emitted before the LeftJoin, and the resulting SQL should execute successfully.

Written by the indexing model from the issue text.

Description

RE: https://datatables.net/forums/discussion/78882/editor-net-mjoin-leftjoin#latest

I think this is a legit bug.

// ...
  .MJoin(new MJoin("InventoryServerWarranty")
      .Set(false)
      .Link("InventoryServer.Id", "InventoryServerInventoryServerWarrantyLine.InventoryServerId")
      .Link("InventoryServerWarranty.Id", "InventoryServerInventoryServerWarrantyLine.InventoryServerWarrantyId")
      .Order("InventoryServerWarranty.CertificateNumber")
      .Model<Warranty>()
      .LeftJoin("InventoryServerWarrantyProvider", "InventoryServerWarrantyProvider.Id", "=", "InventoryServerWarranty.InventoryServerWarrantyProviderId")
  )
// ...

The Editor generated SQL looks like so:

SELECT
    DISTINCT [InventoryServer].[Id] as 'dteditor_pkey',
    [InventoryServerWarranty].[CertificateNumber] as 'CertificateNumber',
    [InventoryServerWarranty].[RegistrationID] as 'RegistrationID',
    [InventoryServerWarranty].[Notes] as 'Notes',
    [InventoryServerWarranty].[DeliveryDate] as 'DeliveryDate',
    [InventoryServerWarranty].[ExpirationDate] as 'ExpirationDate',
    [InventoryServerWarranty].[InventoryServerWarrantyProviderId] as 'InventoryServerWarrantyProviderId',
    [InventoryServerWarranty].[RetiredIncidentNumber] as 'RetiredIncidentNumber',
    [InventoryServerWarranty].[RetiredOn] as 'RetiredOn'
FROM
    [InventoryServer]
    LEFT JOIN [InventoryServerWarrantyProvider] ON [InventoryServerWarrantyProvider].[Id] = [InventoryServerWarranty].[InventoryServerWarrantyProviderId]
    JOIN [InventoryServerInventoryServerWarrantyLine] ON [InventoryServer].[Id] = [InventoryServerInventoryServerWarrantyLine].[InventoryServerId]
    JOIN [InventoryServerWarranty] ON [InventoryServerWarranty].[Id] = [InventoryServerInventoryServerWarrantyLine].[InventoryServerWarrantyId]
WHERE
    [InventoryServer].[Id] IN (2)
ORDER BY
    [InventoryServerWarranty].[CertificateNumber]

Note how that left join is FIRST. That will not work. Only by pulling that down to the be the final join, does the code work.

Dominant language
C#
Stars
19
Forks
11
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from DataTables/NET

All issues in DataTables/NET

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.