You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@empire-db.apache.org by Rainer Döbele <do...@esteam.de> on 2010/01/11 21:25:19 UTC

re: DBCommandExpr.orderBy(), why auto UPPER CASE, adding twice the same column

Hi Exxos,

here are my (personal) comments to your questions:

> If you allow >>> DBColumnExpr.as(<String>)
> then please add the following signature >> DBCommandExpr.orderBy(<String>);
> otherwise there is a gap.

Not quite. In Empire-db we always work with objects not strings. The "as" method creates a new column object and initializes the name property of that object to the string provided. You should then use this object rather than continue working with things.
In your case this means:
DBColumnExpr ALIAS_COL = SOME_COL.as("alias_col");
cmd.select(ALIAS_COL);
cmd.orderBy(ALIAS_COL);
Otherwise we would have to provide string overloads for many more methods and we would loose give up compile time safety completely.

> db.album.title.as("title") will generates the following SQL column name >>> "TITLE" in upper case in the SQL command...
> Is there any reason?
 
Long time ago we decided to make it all upper case. We could have gone for all lower case or left casing completely - but it does not matter. All column, table, view etc. names are case-insensitive and should be treated that way. Hence this is only an issue for debugging and logging. But of course this is something we could talk about.

> Why it is not possible to add twice the same column in a SELECT ?

Why should it? Logically adding the same column twice makes no sense and how could we internally distinguish one from the other? 
If you really need to (as in your UNION example) you can simply rename one of the columns (ABC.as("XYZ")). Internally this would make it another object which we can distinguish and you get the result that you want.


Hope my comments helped you.
Regards

Rainer


Re: DBCommandExpr.orderBy(), why auto UPPER CASE, adding twice the same column

Posted by Francis De Brabandere <fr...@gmail.com>.
On Mon, Jan 11, 2010 at 11:29 PM, Rainer Döbele <do...@esteam.de> wrote:
> Thanks for the info about the case sensitivity of MySql.
>
> In order to maintain code portability Empire-db must ensure that table, view and column names are treated case-insensitive. For some databases this could mean automatically converting names to lower or upper case.

I agree that we should warn about incompatibility for eg two columns
MYCOL and MyCol in one table. But I don't think a tool like empire-db
should enforce any naming rules on it's users.

Cheers,
Francis

>
> Regards,
> Rainer
>
> Francis De Brabandere wrote:
>> re: Re: DBCommandExpr.orderBy(), why auto UPPER CASE, adding twice
>> the same column
>>
>> On Mon, Jan 11, 2010 at 9:25 PM, Rainer Döbele <do...@esteam.de>
>> wrote:
>> > Hi Exxos,
>> >
>> > here are my (personal) comments to your questions:
>> >
>> >> If you allow >>> DBColumnExpr.as(<String>)
>> >> then please add the following signature >>
>> DBCommandExpr.orderBy(<String>);
>> >> otherwise there is a gap.
>> >
>> > Not quite. In Empire-db we always work with objects not strings. The
>> "as" method creates a new column object and initializes the name
>> property of that object to the string provided. You should then use
>> this object rather than continue working with things.
>> > In your case this means:
>> > DBColumnExpr ALIAS_COL = SOME_COL.as("alias_col");
>> > cmd.select(ALIAS_COL);
>> > cmd.orderBy(ALIAS_COL);
>> > Otherwise we would have to provide string overloads for many more
>> methods and we would loose give up compile time safety completely.
>> >
>> >> db.album.title.as("title") will generates the following SQL column
>> name >>> "TITLE" in upper case in the SQL command...
>> >> Is there any reason?
>> >
>> > Long time ago we decided to make it all upper case. We could have
>> gone for all lower case or left casing completely - but it does not
>> matter. All column, table, view etc. names are case-insensitive and
>> should be treated that way. Hence this is only an issue for debugging
>> and logging. But of course this is something we could talk about.
>>
>> This is not the case in MySQL:
>> http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html
>>
>> Cheers,
>> Francis
>



-- 
http://www.somatik.be
Microsoft gives you windows, Linux gives you the whole house.

re: DBCommandExpr.orderBy(), why auto UPPER CASE, adding twice the same column

Posted by Rainer Döbele <do...@esteam.de>.
Thanks for the info about the case sensitivity of MySql.

In order to maintain code portability Empire-db must ensure that table, view and column names are treated case-insensitive. For some databases this could mean automatically converting names to lower or upper case. 

Regards,
Rainer

Francis De Brabandere wrote:
> re: Re: DBCommandExpr.orderBy(), why auto UPPER CASE, adding twice
> the same column
> 
> On Mon, Jan 11, 2010 at 9:25 PM, Rainer Döbele <do...@esteam.de>
> wrote:
> > Hi Exxos,
> >
> > here are my (personal) comments to your questions:
> >
> >> If you allow >>> DBColumnExpr.as(<String>)
> >> then please add the following signature >>
> DBCommandExpr.orderBy(<String>);
> >> otherwise there is a gap.
> >
> > Not quite. In Empire-db we always work with objects not strings. The
> "as" method creates a new column object and initializes the name
> property of that object to the string provided. You should then use
> this object rather than continue working with things.
> > In your case this means:
> > DBColumnExpr ALIAS_COL = SOME_COL.as("alias_col");
> > cmd.select(ALIAS_COL);
> > cmd.orderBy(ALIAS_COL);
> > Otherwise we would have to provide string overloads for many more
> methods and we would loose give up compile time safety completely.
> >
> >> db.album.title.as("title") will generates the following SQL column
> name >>> "TITLE" in upper case in the SQL command...
> >> Is there any reason?
> >
> > Long time ago we decided to make it all upper case. We could have
> gone for all lower case or left casing completely - but it does not
> matter. All column, table, view etc. names are case-insensitive and
> should be treated that way. Hence this is only an issue for debugging
> and logging. But of course this is something we could talk about.
> 
> This is not the case in MySQL:
> http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html
> 
> Cheers,
> Francis

Re: DBCommandExpr.orderBy(), why auto UPPER CASE, adding twice the same column

Posted by Francis De Brabandere <fr...@gmail.com>.
On Mon, Jan 11, 2010 at 9:25 PM, Rainer Döbele <do...@esteam.de> wrote:
> Hi Exxos,
>
> here are my (personal) comments to your questions:
>
>> If you allow >>> DBColumnExpr.as(<String>)
>> then please add the following signature >> DBCommandExpr.orderBy(<String>);
>> otherwise there is a gap.
>
> Not quite. In Empire-db we always work with objects not strings. The "as" method creates a new column object and initializes the name property of that object to the string provided. You should then use this object rather than continue working with things.
> In your case this means:
> DBColumnExpr ALIAS_COL = SOME_COL.as("alias_col");
> cmd.select(ALIAS_COL);
> cmd.orderBy(ALIAS_COL);
> Otherwise we would have to provide string overloads for many more methods and we would loose give up compile time safety completely.
>
>> db.album.title.as("title") will generates the following SQL column name >>> "TITLE" in upper case in the SQL command...
>> Is there any reason?
>
> Long time ago we decided to make it all upper case. We could have gone for all lower case or left casing completely - but it does not matter. All column, table, view etc. names are case-insensitive and should be treated that way. Hence this is only an issue for debugging and logging. But of course this is something we could talk about.

This is not the case in MySQL:
http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html

Cheers,
Francis