Hi,

On Sun, Feb 03, 2008 at 07:07:34PM -0500, John Siracusa wrote:
> Sorry, actually I should have suggested on_load, but no matter because
> something else is obviously wrong.  Can you post a small
> self-contained example including the table definitions and class
> definitions?  That's usually the fastest way to get to the bottom of
> these things.

Test case attached. It's weird. Help! ;)

Note that it'll probably fail on vanilla RDBO due to lack of column
qualifiers.

> 
> > BTW, below is the patch I'm using. If you could have a look at it and
> > check for obvious blunders, I'd be very grateful. I'm including it for
> > the off chance that I broke something by using it.
> 
> That's another thing: why is the table prefix necessary even on
> single-table queries?  I suspect the aforementioned self-contained
> example will illuminate this as well, once I try to run it.
> 
> As for the patch, it looks reasonable but I'd rather understand why
> it's necessary and provide official support for it than encourage you
> to continue using your patch :)

Functions taking rows as arguments may be used like extra table columns
only when qualified with a table alias.

Try this code in PostgreSQL (8.2 is neccessary for multi row inserts but
otherwise it should run on any version):

create table test(id serial primary key, val1 int not null, val2 int not null);
insert into test(val1, val2) values(1,1),(2,2),(3,3),(4,4);
create function is_even(test) returns boolean stable strict as $$ select 
$1.val1 % 2 = 0 $$ language sql;

Now, the unprefixed version:

select id, val1, val2, is_even from test;
ERROR:  column "is_even" does not exist
LINE 1: select id, val1, val2, is_even from test;

And the version with table prefixes:

select t.id, t.val1, t.val2, t.is_even from test t;
 id | val1 | val2 | is_even
 ----+------+------+---------
   1 |    1 |    1 | f
   2 |    2 |    2 | t
   3 |    3 |    3 | f
   4 |    4 |    4 | t

BTW, I noticed that 0.7662 qualifies column names in ORDER BY clauses.
Nice :) That fixed another problem of mine, too (allows sorting on
function columns).

Best regards,
 Grzegorz Nosek

Attachment: rdbo_computed_functions.tar.gz
Description: Binary data

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to