Re: Re: Aggregations etc.

Franck Routier <[email protected]> Sun, 19 Apr 2009 08:49:57 +0200
Newsgroups gmane.comp.java.orm.simpleorm
Message-ID <1240123797.4204.48.camel@franck-laptop>
Hello Anthony,

I've not be changing anything recently, except adding a rawInnerJoin
method to SQuery, that truly adds an arbitrary table to a query (a table
that has no explicit SFieldReference to the query).

But I have also found I would need rawSelect(), so it is definitely a
good idea :-)

The point is we are also releasing a new version of our flgship product
by the end of the month, so I'll be quite busy right until then...

Just a few more comments:

> I think that specifically SQueryAggregate and friends should be renamed into something like SQueryGeneric.  That is because the thing that is special about it is that it returns SRecordGenerics rather than SRecordInstances.  One use of SQueryGeneric is to do aggregates, but it is more general than that.

Yes, but then, when SRecordInstance will extend SRecordGeneric, SQuery
will also return SRecordGeneric... So, are we going to have an abstract
SQueryGeneric, with SQuery and SAggregateQuery extending it, or do you
think both should be merged in the long term ? (right now I wouldn't say
so, but I'm not sure)
> 
> Thus we should also add the easy 
>   .rawSelect(String rawSqlExpression, Object[]... parameters) 
> which adds an arbitrary an arbitrary expression, plus .rawClause for completeness.

Yes, that would be interesting...
Another thing I found I'm missing is doing arbitray calculation and then
doing an aggregate on it, but rawSelect wouldn't solve my problem
altogether, as calculation might include database functions that are not
standard.
Typical example is I want to make a sum of durations for my records,
grouped by whatever. Duration is defined by the difference between two
timestamps... and this is something that in not standard in sql. So
having portable code is not easy.

eg. select sum( extract(epoch from endts) - extract(epoch from begints))
will work for postgresql, but not for oracle etc.

So another idea I had was to be able to augment SDriver (and
SQueryGeneric) with specific functions (like duration(ts1, ts1)) that
could be used in queries to allow to generate sql that will work in each
database... I didn't do anything for now, as I'm not sure about the
right way to do this (just add the functions I need, or think about a
more clever pluggable functions system, ...)

> 
> The simple unification of SRecordInstance with SRecordGeneric would complete the process, but that can be done later.  I might make time do it myself because it will not affect your code.  (It is easy, just have SRecordInstance implement map, with 
> 
Fine.
As I said, I won't have much time for the next two or hree weeks, but it
should be better after that.

Best regards,
Franck




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

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/SimpleORM/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/SimpleORM/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[email protected] 
    mailto:[email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/