From: Bjorn B. <bri...@cs...> - 2007-12-18 11:33:26
|
Hi Justin, this looks good. I haven't run the testsuite yet, since it still =20 requires hs-plugins. I really should get around to fixing that. Hope =20 seems to run fine with it. I'll be happy to push this to the main repo. Would it be possible for =20= you to send me an updated patch with only the necessary changes? Some =20= of the changes in the patch seem to only affect whitespace. I prefer =20 to keep patches minimal. /Bj=F6rn On Dec 11, 2007, at 21:53 , Justin Bailey wrote: > All, > > Attached you'll find a patch that removes the mandatory "DISTINCT" > clause from select statements. Instead, if a query has the "unqiue" > function applied, a 'group by' statement will appear in the select, > grouping by all non-aggregate columns. This works properly with > optimization so unused columns do not appear in the group-by. Note > this patch replaces my previous one - I think this approach is a lot > better and works in more situations. > > One change I'm unsure of is that "unique" is NOT default behavior > anymore. I think a select statement with a "distinct" on all columns > is very surprising so I like the change. Others may disagree. > > A summary of significant changes: > > M ./src/Database/HaskellDB/PrimQuery.hs -3 +7 > * Added "Group" value to PrimQuery. This value holds an association > list and a query. The association list is the columns/expressions that > will be grouped; the query is the query to which Group was applied. In > SQL, grouping can happen on expressions, which is why an Assoc list is > used instead of a simple list of column names. > > > M ./src/Database/HaskellDB/Query.hs -9 +30 > * Added the 'unique' function, which causes the Group value to be > added to the query. All currently projected columns are examined and > non-aggregates are added to the Group value. This allows those columns > to be later generated in a "group by" statement. > > M ./src/Database/HaskellDB/Sql/Generate.hs +3 > * Added 'sqlGroup' field to SqlGenerator value. Used to process =20 > Group values. > > M ./src/Database/HaskellDB/Sql.hs -12 +16 > * Changed the 'groupby' field from a list of SqlExpr to a list of > (SqlColumn, SqlExpr) pairs. Not really needed right now, but will > allow 'GROUP BY' to be as expressive as the 'column list' available to > SELECT. > > M ./src/Database/HaskellDB/Sql/Default.hs -8 +12 > * Added 'defaultSqlGroup' converts the Assoc list from the Group value > to a list of (SqlColumn, SqlExpr) pairs and stores them in the groupby > field. > * Note that defaultSqlSelect did NOT have to change - it already > handled grouping for non-aggregate expressions properly. > > M ./src/Database/HaskellDB/Sql/Print.hs -3 +9 > M ./src/Database/HaskellDB.hs -1 +1 > M ./src/Database/HaskellDB/Optimize.hs -7 +16 > * Various small changes to support new values and changed structures. > > I welcome feedback on this patch. I'm happy to clarify anything or > provide examples. > > Justin<JGBAILEY.12112007.patch.txt> |