Can you send cvs diffs?

----- Original Message -----
From: fanyun <[EMAIL PROTECTED]>
To: Turbine <[EMAIL PROTECTED]>
Sent: Tuesday, August 15, 2000 8:56 AM
Subject: Re: a change to BasePeer.


> Hi,
>
> As I understand, if you want to do a
>        select Userid from Users;
>
> With peer, You just write:
>
>  criteria.addSelectColumn("Users.USERID");
>   BasePeer.doSelect(criteria);
>
> Then you may wonder how turbine knows which table to use. BasePeer will
get
> the table name from the string before the dot.
> it will send a:
>
>     select Users.Userid from Users;
>
> to database.
>
>
> Now consider you want to do a
>
>     select count(Userid) from Users;
>
> If you do it this way:
>     criteria.addSelectColumn("Users.count(USERID)");
>
> BasePeer will send     select  Users.count(USERID) from Users;    to
> database.  This is illigue to any database.
>
> If you do it this way:
>
>     criteria.addSelectColumn("count(USERID)");
>
> Base Peer will never know which table you are using.
>
> So I provide a solution is:
>
>     criteria.addSelectColumn("count(Users.USERID)");
>
> With my change to BasePeer, the result will be :     select
> count(Users.Userid) from Users;
>
> Now the problem solve. The same problem will also happened to min()  Max()
> functions.
>
>
> Do you think it is a problem and do you have any better solution?
>
>
>
>
> Regards
>
>
> fanyun
>
>
>
>
>
>
>
> ----- Original Message -----
> From: "John McNally" <[EMAIL PROTECTED]>
> To: "Turbine" <[EMAIL PROTECTED]>
> Sent: Tuesday, August 15, 2000 1:01 AM
> Subject: Re: a change to BasePeer.
>
>
> > Can you explain why this is not handled better by BasePeer.executeQuery?
> >
> > ----- Original Message -----
> > From: fanyun <[EMAIL PROTECTED]>
> > To: Turbine <[EMAIL PROTECTED]>
> > Sent: Sunday, August 13, 2000 8:35 AM
> > Subject: a change to BasePeer.
> >
> >
> > > Hi all:
> > >
> > > Today, I want to do a
> > >
> > >             select count(*) from Users;
> > >
> > > by using peer.
> > >
> > > But I was stopped. After study, I find Peer get table name from the
> first
> > > part of Column name. That means if I should pass   Users.UserName into
> > peer,
> > > peer will get the table name and send:
> > >
> > >         select Users.Username from Users;
> > >
> > > Now
> > >
> > > 1. if I pass    count(*)  to peer,  peer do not know which table to
use
> > > 2. if I pass   Users.count(*)  to peer, peer will send
> > >         select Users.count(*) from Users;
> > > This is illugae to any database.
> > >
> > > Of cause I can just select something from the table and count the
> returns,
> > > but I think it is a waste of system resource, and will slow down the
> > > performance. And if using max()   min ....   functions, we will again
> met
> > > this problem.
> > >
> >
>
> --------------------------------------------------------------------------
> > --
> > > -----------------------------------------------
> > > Solution:    I changed BasePeer
> > >
> > > function name:
> > >  public static String createQueryString( Criteria criteria ) throws
> > > Exception
> > >
> > >
> > >
> > >         for (int i=0; i<select.size(); i++)
> > >         {
> > >             String columnName = select.get(i);
> > >             selectClause.add(columnName);
> > >
> > >             int braceplace = columnName.indexOf('(');
> > >             if(braceplace == -1)
> > >
> > >
> > >
> > > fromClause.add(columnName.substring(0,columnName.indexOf('.') ));
> > >             }
> > >             else
> > >             {
> > >
> > >
> >
>
fromClause.add(columnName.substring(braceplace+1,columnName.indexOf('.') ));
> > >             }
> > >         }
> > >
> > > Now you can just pass:    count(Users.UserID)  into peer.  Peer will
get
> > the
> > > table name and send
> > >
> > >         select count(Users.Userid) from Users;
> > >
> > >
> > > This works, and for min, max  it also works
> > >
> >
>
> --------------------------------------------------------------------------
> > --
> > > --
> > >
> > > This is my first time contribute a small change, will you take this
> > > change???
> > >
> > > Vote + 1
> > >
> > >
> > > Regards
> > >
> > > fanyun
> > >
> > >
> > >
> > >
> > > ------------------------------------------------------------
> > > To subscribe:        [EMAIL PROTECTED]
> > > To unsubscribe:      [EMAIL PROTECTED]
> > > Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
> > > Problems?:           [EMAIL PROTECTED]
> > >
> >
> >
> >
> > ------------------------------------------------------------
> > To subscribe:        [EMAIL PROTECTED]
> > To unsubscribe:      [EMAIL PROTECTED]
> > Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
> > Problems?:           [EMAIL PROTECTED]
> >
>
>
>
> ------------------------------------------------------------
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
> Problems?:           [EMAIL PROTECTED]
>



------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to