Re: [RDBO] RDBO and computed columns

2008-02-04 Thread Grzegorz Nosek
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



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/vse012070mrt/direct/01/___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] RDBO and computed columns

2008-02-04 Thread John Siracusa
On Feb 4, 2008 4:05 PM, John Siracusa [EMAIL PROTECTED] wrote:
 On Feb 4, 2008 3:51 PM, Grzegorz Nosek [EMAIL PROTECTED] wrote:
  Functions taking rows as arguments may be used like extra table columns
  only when qualified with a table alias.

 Can you use an alternate normal function call form as well?

 SELECT id, ..., is_even(...) FROM test;

 I'm not sure what'd go in (...), however.  Anyway, is there a syntax
 form like that?

It looks like this works:

SELECT id, val1, val2, is_even(test) FROM test;

In which case you can try making a custom column type as per:

http://www.mail-archive.com/rose-db-object@lists.sourceforge.net/msg00710.html

...although I think it'll be kind of ugly since the table name will
need to appear in there.  It's also not a flexible as having it just
work as a normal column specifier, so I'll see what I can do about
adding an option to unconditionally qualify columns in single-object,
single-table load() queries.

(still working on the column modification thing...)
-John

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


[RDBO] ANNOUNCE: Rose::DB::Object 0.7663 released

2008-02-04 Thread John Siracusa
More bug fixes that I didn't want to wait until the next major release.

-John

0.7663 (02.04.2008) - John Siracusa [EMAIL PROTECTED]

* Fixed a bug that caused delete_on_save method creation for foreign
  keys to fail in some circumstances.  (Reported by Justin Ellison)
* Fixed a bug that prevented Perl code from being emitted for
  non-set columns with check_in attributes.  (Reported by Sam Tregar)
* Pushed cache control methods down into Rose::DB::Object::Cached
  in preparation for more caching subclasses.
* The clear_object_cache() method now correctly clears load timestamps
  as well.  (Patch by Justin Ellison)

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


Re: [RDBO] RDBO and computed columns

2008-02-04 Thread John Siracusa
On Feb 4, 2008 3:51 PM, Grzegorz Nosek [EMAIL PROTECTED] wrote:
 Functions taking rows as arguments may be used like extra table columns
 only when qualified with a table alias.

Can you use an alternate normal function call form as well?

SELECT id, ..., is_even(...) FROM test;

I'm not sure what'd go in (...), however.  Anyway, is there a syntax
form like that?

 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).

Yeah, and around 0.765 all tables in Manager queries got unconditional
qualifiers too.

(haven't looked at your example yet)
-John

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


Re: [RDBO] RDBO and computed columns

2008-02-04 Thread John Siracusa
On Feb 4, 2008 3:51 PM, Grzegorz Nosek [EMAIL PROTECTED] wrote:
 Test case attached. It's weird. Help! ;)

Not so weird: it was a simple bug in the boolean method maker.  It's
fixed in SVN now.  I'll work on the column name qualification option.

-John

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