incubator-empire-db-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rainer Döbele <doeb...@esteam.de>
Subject re: DBCommandExpr.orderBy(), why auto UPPER CASE, adding twice the same column
Date Mon, 11 Jan 2010 20:25:19 GMT
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


Mime
View raw message