Skip to content

SQL Server ORDER BY and DISTINCT is not parsed #75

@unruledboy

Description

@unruledboy

The following query has order by clause:

SELECT p.Name FROM Production.Product p inner join dbo.productdetails pd on p.id=pd.productid
group by p.Name
order by p.name

And even with MsSqlDialect, the following sample code will return select.SortBy as null:

 var sql = @"SELECT p.Name FROM Production.Product p inner join dbo.productdetails pd on p.id=pd.productid
group by p.Name
order by p.name"
 var statements = new Parser().ParseSql(sql, new MsSqlDialect());
 foreach (var item in statements)
 {
     if (item is Statement.Select selectStatement)
     {
         var select = selectStatement.Query.Body.AsSelect();

        // select.SortBy is null
      }
}
Image

And the issue happens with DISTINCT:

SELECT distinct p.[Name] FROM Production.Product p inner join dbo.productdetails pd on p.id=pd.productid

The select.DistributeBy is null.

Is there specific option that we need to use to support it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions