Aight, that would be cool. So this still has to be implemented then,
right?
To be honest, I am not really up to date on the theory behind this
change but I have enough trust to assume it's a good thing :-)
I was playing around and found out that the faulty SQL it generated is
like this:
Test=# INSERT INTO request (id, metanumberstate) VALUES (1,
coalesce(max(metanumber.id), 0));
ERROR: missing FROM-clause entry for table "metanumber" at character
67
But when I do it with a subquery (by hand) it does work.
Test=# INSERT INTO request (id, metanumberstate) VALUES (1, (SELECT
max(metanumber.id) FROM metanumber));
Query OK, 1 rows affected (0.00 sec)
Anyway, I made a test script, you might find it useful. It's test.py
under files
Cheers, Koen
I was just creating a test script for this.
On Sep 6, 4:14 pm, Michael Bayer <[EMAIL PROTECTED]> wrote:
> all the default SQL functions are being executed "inline" here. so
> it doesnt like aggregates like "max" being placed into defaults like
> that.
>
> the best I can do for you here, other than rolling back the entire
> "inilne" default thing, would look like this:
>
> Column('foo', Integer, ColumnDefault(func.coalesce(func.max
> (metanumber_table.c.id), 0), inline=False))
>
> so that it gets the hint to "pre-execute" that default.
>
> On Sep 6, 2007, at 8:44 AM, Koen Bok wrote:
>
>
>
> > Hi there, I am upgrading my app to 0.4 and while it's going pretty
> > well, I encountered something strange.
>
> > I have the following code:
>
> > request_table = Table('request', metadata,
> > Column('id', Integer, primary_key=True),
> > ...
> > Column('metanumberstate', Integer, nullable=False,
> > default=func.coalesce(func.max(metanumber_table.c.id), 0)),
> > ...
> > )
>
> > And this is bound to the Request object. But when I init a new
> > instance and commit it I get an error (see below). But this always
> > worked (0.3.x) so I have no clue what I am doing wrong. Anyone has a
> > hint?
>
> > ProgrammingError: (ProgrammingError) missing FROM-clause entry for
> > table "metanumber"
> > LINE 1: ...uest), NULL, 5, 1, 2, 3, 2, NULL, 7,
> > coalesce(max(metanumber...
> > ^
> > 'INSERT INTO request (id, number, id_parent, id_item, id_employee,
> > id_terminal, id_location, srcstocktype, dststocktype, metadatastate,
> > metanumberstate, metataxstate, quantity, discount, over ride_price,
> > allocation, date, is_business, has_tax, is_quote) VALUES (%(id)s,
> > (SELECT coalesce(max(number), 0) + 1 FROM request), %(id_parent)s, %
> > (id_item)s, %(id_employee)s, %(id_terminal)s, %(id_location)s, %
> > (srcstocktype)s, %(dststocktype)s, %(metadatastate)s,
> > coalesce(max(metanumber.id), %(coalesce)s), coalesce(max
> > (metatax.id), %
> > (coalesce_1)s), %(quantity)s, %(discount)s, %(override_price)s, %
> > (allocation)s, now(), %(is_business)s, %(has_tax)s, %
> > (is_quote)s)' {'id_item': 5L, 'is_business': False, 'srcstocktype': 2,
> > 'is_quote': False, 'coalesce_1': 0, 'id_terminal': 2L, 'id_parent':
> > None, 'id_employee': 1L, 'allocation': 0, 'coalesce': 0,
> > 'id_location': 3L, 'has_tax': True, 'override_price': None,
> > 'dststocktype': None, 'discount': None, 'quantity': 1, 'id': 1L,
> > 'metadatastate': 7L}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---