Good evening Michael,

On 09/04/2012 20:05, Michael Bayer wrote:
even google is not telling me which vendor has produced this expression.  Because 
"computed by" is the most generic phrase.

I see a brief mention in firebird's docs ?   no clue.
Sorry, should have mentioned that currently I use Firebird SQL 2.5. BTW, it is the first FB release which supports an "alter" column to change the computed by clause.

I'd probably use @compiles on top of CreateTable for this, and use a regular expression 
to tokenize out the columns that have "computed_by" in their info field.

To really support extensions like this fully we'd have to break out compiler to 
make usage of a CreateColumn directive, then you'd be able to put @compiles on 
top of CreateColumn and generate the columns directly.   wouldn't be too 
terrible but 0.8 is quite backlogged (see 
http://www.sqlalchemy.org/trac/ticket/2463).

Or why not do it at the type level ?   Can you just make a UserDefinedType here 
?
Will look into these.
    2463 might be nicer.
and will keep watching this one in case it does make it into 0.8.

Thanks
Werner




On Apr 9, 2012, at 1:36 PM, Werner wrote:

Is there a way in SA 0.7.6 to define computed columns as part of other 
DeclarativeBase columns?

Currently I do manual DDL, but would like to get things setup to be able to 
easier move to another db backend.

Most of my computed columns are calculations like the one on AVAILCAPACITY 
below, but also have a few simple selects like in the USEDCAPACITY column.

CREATE TABLE WINERACKIT (
    WINERACKITID    PKEYS NOT NULL,
    SPLIT           INTEGER NOT NULL,
    CAPACITY        INTEGER DEFAULT 0,
    FK_WINERACKBID  PKEYS NOT NULL /* PKEYS = BIGINT */,
    USEDCAPACITY    COMPUTED BY ((SELECT COUNT(BOTTAG.TAGNO) FROM BOTTAG WHERE 
BOTTAG.FK_WINERACKIT_ID = WINERACKIT.ID)),
    AVAILCAPACITY   COMPUTED BY (CAPACITY-USEDCAPACITY)

Thanks in advance for some pointers on how to do this.

Werner

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.


--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to