Skip to content

Query: Distinct followed by other operations can give rise to incorrect SQL #7525

Closed

Description

@smitpatel

SQL generated by following tests is invalid and throws exception.
There can be more variations which may fail too.

[ConditionalFact]
public virtual void OrderBy_coalesce_take_distinct()
{
	AssertQuery<Product>(
		ps => ps.OrderBy(p => p.UnitPrice ?? 0)
			.Take(15)
			.Distinct()
			.Select(p => new {Price = p.UnitPrice ?? 0}),
		assertOrder: false,
		entryCount: 15);
}


[ConditionalFact]
public virtual void OrderBy_skip_take_distinct()
{
	AssertQuery<Customer>(
		cs => cs.OrderBy(c => c.ContactTitle)
			.ThenBy(c => c.ContactName)
			.Skip(5)
			.Take(15)
			.Distinct()
			.OrderBy(c => c.ContactTitle)
			.Take(8),
		assertOrder: false,
		entryCount: 8);
}

Activity

  1. changed the title [-]Distinct followed other operations can give rise to incorrect SQL[/-] [+]Distinct followed by other operations can give rise to incorrect SQL[/+] on Feb 3, 2017
  2. added 7 commits that reference this issue on Feb 4, 2017
    76f076b
    a3b2caa
    a3e5efc
    9901e32
    c5e0555
    5652a69
    52561bd
  3. added this to the 2.0.0 milestone on Feb 10, 2017
  4. modified the milestones: , 2.0.0 on Apr 19, 2017
  5. modified the milestones: , 2.0.0 on Apr 21, 2017
  6. changed the title [-]Distinct followed by other operations can give rise to incorrect SQL[/-] [+]Query: Distinct followed by other operations can give rise to incorrect SQL[/+] on May 9, 2017
  7. modified the milestones: , 2.0.0 on Oct 15, 2022
  8. added theissue type on Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions