Skip to content

Commit

Permalink
Reverts code for #89.
Browse files Browse the repository at this point in the history
  • Loading branch information
perdjurner committed Aug 20, 2014
1 parent b036610 commit 26f827b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
1 change: 0 additions & 1 deletion wheels/CHANGELOG
Expand Up @@ -17,7 +17,6 @@ Bug Fixes
* Fixed bug with static caching on Adobe ColdFusion 9 - #332 [Charley Contreras]
* Allow for format auto-detection when HTTP ACCEPT contains multiple values - #297 [Raul Riera, Singgih Cahyono]
* Fixed so that sendEmail() can use the "remove" attribute to delete attachments - #339 [Simon Allard]
* Fixed issue with using group by with calculated properties - #89 [Adam Chapman, Per Djurner]

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Expand Down
7 changes: 2 additions & 5 deletions wheels/model/sql.cfm
Expand Up @@ -175,18 +175,15 @@
// if we want a distinct statement, we can do it grouping every field in the select
if (arguments.distinct)
{
loc.returnValue = $createSQLFieldList(list=arguments.select, include=arguments.include, returnAs=arguments.returnAs, renameFields=false, addCalculatedProperties=true);
loc.returnValue = $createSQLFieldList(list=arguments.select, include=arguments.include, returnAs=arguments.returnAs, renameFields=false, addCalculatedProperties=false);
}
else if (Len(arguments.group))
{
loc.returnValue = $createSQLFieldList(list=arguments.group, include=arguments.include, returnAs=arguments.returnAs, renameFields=false, addCalculatedProperties=true);
loc.returnValue = $createSQLFieldList(list=arguments.group, include=arguments.include, returnAs=arguments.returnAs, renameFields=false, addCalculatedProperties=false);
}
if (Len(loc.returnValue))
{
loc.returnValue = "GROUP BY " & loc.returnValue;
// this is a little ugly because I want to contain any possible issues to group by for 1.3.x releases
// for 2.0.x we should probably strip out the " AS x" part in the $createSQLFieldList function instead
loc.returnValue = REReplaceNoCase(loc.returnValue, " AS [a-z0-9-_]*", "", "all");
}
</cfscript>
<cfreturn loc.returnValue>
Expand Down
5 changes: 3 additions & 2 deletions wheels/tests/_assets/models/User2.cfc
Expand Up @@ -3,8 +3,9 @@
<cffunction name="init">
<cfset settablenameprefix("tbl")>
<cfset table("users")>
<cfset property(name="firstLetter", sql="SUBSTRING(tblusers.username, 1, 1)")>
<cfset property(name="groupCount", sql="COUNT(tblusers.id)")>
<!--- uncomment for testing "test_group_by_calculated_property" --->
<!--- <cfset property(name="firstLetter", sql="SUBSTRING(tblusers.username, 1, 1)")>
<cfset property(name="groupCount", sql="COUNT(tblusers.id)")> --->
</cffunction>

</cfcomponent>
4 changes: 2 additions & 2 deletions wheels/tests/model/crud/group.cfc
Expand Up @@ -5,10 +5,10 @@
<cfset assert('loc.r.recordcount eq 4')>
</cffunction>

<cffunction name="test_group_by_calculated_property">
<!--- <cffunction name="test_group_by_calculated_property">
<cfset loc.r = model("user2").findAll(select="firstLetter, groupCount", group="firstLetter", order="groupCount DESC")>
<cfset assert('loc.r.recordcount eq 2')>
</cffunction>
</cffunction> --->

<cffunction name="test_distinct_works_with_group_by">
<cfset loc.r = model("post").findAll(select="views", distinct=true)>
Expand Down

0 comments on commit 26f827b

Please sign in to comment.