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

Support queries having no "from" clause (MSSQL only?) #291

Open
davidAtInleague opened this issue Jan 22, 2025 · 0 comments
Open

Support queries having no "from" clause (MSSQL only?) #291

davidAtInleague opened this issue Jan 22, 2025 · 0 comments

Comments

@davidAtInleague
Copy link
Contributor

davidAtInleague commented Jan 22, 2025

In MSSQL, the following is valid

select 42

I don't doubt that there are occasionally justifiable usages of the above pattern. But it is certifiably useful alongside {cross,outer}Apply, where the current row is just being laterally extended:

select users.ID, computedUserAge.xage
from users
cross apply (
  select 42 + users.age as xage
) computedUserAge
where computedUserAge.xage > 999

Maybe this can be as simple as updating SqlServerGrammer.cfc to override compileFrom:

private string function compileFrom( required QueryBuilder query, required any from ) {
    var clause = super.compileFrom(
        query = query,
        from = from
    )

    if (trim(clause) == "from") {
        return ""
    }
    else {
        return clause;
    }
}
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

No branches or pull requests

1 participant