Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query Expresion Formatting - Joins #3156

Open
4 tasks
Eddonomochi opened this issue Mar 3, 2025 · 1 comment
Open
4 tasks

Query Expresion Formatting - Joins #3156

Eddonomochi opened this issue Mar 3, 2025 · 1 comment

Comments

@Eddonomochi
Copy link

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.

@nojaf
Copy link
Contributor

nojaf commented Mar 4, 2025

Hello, thank your for brining this up.
I saw that atCurrentColumn in

+> atCurrentColumn (genExpr node.RightHandSide)
is the cause of this.
I'm not sure if this is historically of required to have valid code elsewhere.

Someone should investigate this to be sure. Maybe we can improve this a bit.
Are you interested in taking a stab at this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants