theres three layers to this issue. the first is, yes as_scalar() is
trying to compile the expression which I don't think there's a very
good reason, so ill likely commit a change for that (it will result in
a behavioral change regarding the namespace of "someselect.c" but im
hoping not one anyone was relying upon that). the second layer is,
if you're casting against a constant value like below, or a column on
the Order class, you don't need the select() - just say
cast(...).label('foo') - however, convenient operations like "print
query" still wont work since they evaulate the cast() without a
dialect. the third is, the whole "cast can't compile without a
dialect" thing is going away in 0.6, but I can't make it work in 0.5
without major changes.
One particular workaround that would totally eliminate the issue until
0.6 comes out would be to use the dialect-specific type for now, i.e.
MSNumeric (mysql), PGNumeric (postgres), SLNumeric (sqlite).
On Mar 22, 2009, at 6:27 AM, Shawn Church wrote:
> >>> import sqlalchemy
> >>> sqlalchemy.__version__
> '0.5.2'
>
> >>> from sqlalchemy import *
> >>> from sqlalchemy.orm import relation, column_property,
> sessionmaker
>
> >>> from sqlalchemy.ext.declarative import declarative_base
> >>> Base = declarative_base()
> >>> Session = sessionmaker()
>
> >>> class Order(Base):
> ... __tablename__ = "orders"
> ...
> ... id = Column(Integer, primary_key = True)
> ...
> ... test = column_property(select([cast(1,
> Numeric(14,2))]).label("test"))
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---