Left join entity is never null

Open
#697 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Quiet
Tech stack
fsharp, sql
Domain
databases

Research direction

No source file or test is named. Start by reproducing both query forms from the issue against SQLProvider v1.1.93, focusing on leftOuterJoin, DefaultIfEmpty(), and the reported default-valued entity. Done means documenting or testing the supported syntax and the expected missing-entity behavior.

Written by the indexing model from the issue text.

Description

Describe the bug
I am trying to left join "sheets" entity but I can't get it to work properly.

The documentation says that leftOuterJoin is not supported, but I see examples on stackoverflow of people saying this works.
For me it does not.

query {
        for e in ctx.Dbo.TimeEntries do
        join t in ctx.Dbo.ProjectTasks on (e.TaskId = t.Id)
        leftOuterJoin sheet in ctx.Dbo.DrawingLogSheets on (e.SheetId = Some sheet.Id) into sheetResults
        for s in sheetResults.DefaultIfEmpty() do
        where (e.Email = Some email && e.Date = dateOnly)
        select (toTimeEntry(e, t, s))
    }

This fails with an error.

I also tried this approach:

query {
        for e in ctx.Dbo.TimeEntries do
        join t in ctx.Dbo.ProjectTasks on (e.TaskId = t.Id)
        join s in (!!) ctx.Dbo.DrawingLogSheets on (e.SheetId = Some s.Id)
        where (e.Email = Some email && e.Date = dateOnly)
        select (toTimeEntry(e, t, s))
    }

This kind of works, but sheet is never null when it is missing; instead, it has all its values defaulted. For example, its ID field is a new guid (all zeros), and its string values are all empty string. I suppose I could check for defaulted guid, but this just feels like something is not right.

To Reproduce

Expected behavior
In the first example (leftOuterJoin), I just want to verify whether this syntax is supposed to be supported or not.
In the second example (!!), I would expect the sheet entity to be null when no sheet is joined, but instead it is instantiated with all default values.

Screenshots

Desktop (please complete the following information):

  • Windows
  • SQLProvider is v1.1.93

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Dominant language
F#
Stars
627
Forks
147
Avg merge
2h 2m
Merged PRs (30d)
1

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 fsprojects/SQLProvider

All issues in fsprojects/SQLProvider

Similar issues

More Databases issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.