Bugs
Search the entire project
This project's trackers
This project's forums
This project's tasks
This project's releases
This project's documents
This project's news
Project
People
Skill
Advanced search
Log In
|
New Account
Home
My Page
Projects
Code Snippets
Project Openings
Npgsql .Net Data Provider for Postgresql
Summary
Activity
Forums
Tracker
Lists
Tasks
Docs
Surveys
News
SCM
Files
[#1010863] GroupBy Expression with two or more parameters creates a sql error
View Trackers
|
Bugs
|
Download .csv
|
Monitor
Date:
2010-08-05 20:03
Priority:
3
State:
Open
Submitted by:
Andreas Winkler (
magicmanone
)
Assigned to:
Nobody (None)
Npgsql Version:
2.0.9
Category:
Group:
Resolution:
None
Summary:
GroupBy Expression with two or more parameters creates a sql error
Detailed description
Hi,
I found a bug in the implementation of the internal class GroupByExpression (Npgsql V2.0.9 and V2.0.10).
If you want to group with only one parameter then the implementation is correct, but by two or more parameter to group the generated sql misses the comma.
Solution: the method 'AppendGroupingKey' below
internal class GroupByExpression : VisitedExpression
{
private bool _requiresOrderSeperator;
public void AppendGroupingKey(VisitedExpression key)
{
if (_requiresOrderSeperator)
Append(",");
Append(key);
_requiresOrderSeperator = true;
}
internal override void WriteSql(StringBuilder sqlText)
{
if (ExpressionList.Count != 0)
sqlText.Append(" GROUP BY ");
base.WriteSql(sqlText);
}
internal override IEnumerable<ColumnExpression> GetProjectedColumns()
{
return Enumerable.Empty<ColumnExpression>();
}
}
With best regards
Andreas
Followup
Message
Date: 2010-08-13 13:42
Sender:
Andreas Winkler
I have tested the cvs code with your patches. So far I was
not able to reproduce the issue anymore.
Thanks,
Andreas
Date: 2010-08-09 02:23
Sender:
Josh Cooley
I had no luck getting the GroupBy method to translate to GROUP BY SQL until I ran the Entity Framework Query Samples. It must have been something about my model that wasn't quite right to produce that query tree. In the end I was able to reproduce this issue as well as an issue with constants showing up in the group by clause.
Please test the code in CVS if you get a chance.
Date: 2010-08-07 20:57
Sender:
Andreas Winkler
Hi Josh,
my example:
...db.Data.Where(em => em.AccessDate.Value.Year == 2010
&& em.AccessDate.Value.Month == 8).GroupBy(em => new
em
{
em.CardNumber,
em.DataType
}).Select(ez => ez);
this expression generates a sql expression like 'GROUP BY
EXTEND1.CardNumberEXTEND1.DataType'. The comma between
CardNumber and DataType is missing.
Andreas
Date: 2010-08-06 03:13
Sender:
Josh Cooley
Thank you for pointing this out. Can you provide a sample query that would demonstrate this bug?
Attached Files:
Changes:
No Changes Have Been Made to This Item