Skip to content

Query Expresion Formatting - Joins #3156

@Eddonomochi

Description

@Eddonomochi

Issue created from fantomas-online

Code

let exampleCode
    (database : dbContext)
    (id : int)
    : Async<ReturnType list> =
    async {
        return!
            query {
                for persons in database1 do
                    join items in database2 
                        on ((persons.LongIdName, persons.LongerIdName) = (items.LongIdName, items.LongerIdName)) 
                        into result
                    for i in result.DefaultIfEmpty() do 
                        select (a.LongIdName, a.AccountId)
                        distinct
            }
            |> AsyncExtensions.ToArrayAsync
            |> Async.AwaitTask
    }

Result

let exampleCode (database: dbContext) (id: int) : Async<ReturnType list> =
    async {
        return!
            query {
                for persons in database1 do
                    join items in database2
                                      on
                                      ((persons.LongIdName, persons.LongerIdName) = (items.LongIdName,
                                                                                     items.LongerIdName))
                                      into
                                      result

                    for i in result.DefaultIfEmpty() do
                        select (a.LongIdName, a.AccountId)
                        distinct
            }
            |> AsyncExtensions.ToArrayAsync
            |> Async.AwaitTask
    }

Problem description

Hey there! I am just curious what is going on here. I have an example query expression here and the formatting seems off. The example code is how I'd expect the formatter to handle the query expression. Yet, it always seems to want to add the extra indentations before the on and any following related clauses. This issue happens both locally and when I try the online tool; both while trying with default configurations and trying different settings to see if it would fix it. Not sure if query formatting is something being looked into or not, but I thought I would bring it up here and see if it's something I am missing or a possible point of improvement.

Extra information

  • The formatted result breaks my code.
  • The formatted result gives compiler warnings.
  • I or my company would be willing to help fix this.
  • I would like a release if this problem is solved.

Options

Fantomas main branch at 2025-02-28T11:18:04Z - 6108fc4

Default Fantomas configuration

Did you know that you can ignore files when formatting by using a .fantomasignore file?
PS: It's unlikely that someone else will solve your specific issue, as it's something that you have a personal stake in.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions