Re: [RDBO] RDBO and computed columns

2008-02-06 Thread Grzegorz Nosek
On Wed, Feb 06, 2008 at 08:29:49PM +0100, Grzegorz Nosek wrote: > Still, either I'm doing something very stupid, or the columns are now > always qualified, like this: > > SELECT > t1.id, > t1.val1, > t1.val2, > t1.is_even > FROM > test t1 > WHERE > t1.id = ? AND > t1.is_even = ? (2,

Re: [RDBO] RDBO and computed columns

2008-02-06 Thread Grzegorz Nosek
On Tue, Feb 05, 2008 at 07:04:10PM -0500, John Siracusa wrote: > On Feb 5, 2008 5:16 PM, Grzegorz Nosek <[EMAIL PROTECTED]> wrote: > > Hmm, I might be missing something, but inside the > > sql_qualify_columns_on_load method you're using $_[1] after shifting > > $self off the argument array, so to s

Re: [RDBO] RDBO and computed columns

2008-02-05 Thread John Siracusa
On Feb 5, 2008 5:16 PM, Grzegorz Nosek <[EMAIL PROTECTED]> wrote: > Hmm, I might be missing something, but inside the > sql_qualify_columns_on_load method you're using $_[1] after shifting > $self off the argument array, so to set the value to true, I must pass > two arguments to the method Too sl

Re: [RDBO] RDBO and computed columns

2008-02-05 Thread Grzegorz Nosek
Hi, On Tue, Feb 05, 2008 at 04:18:28PM -0500, John Siracusa wrote: > On Feb 5, 2008 4:06 PM, Grzegorz Nosek <[EMAIL PROTECTED]> wrote: > > t/db-objectok 1/566# Looks like you planned 566 > > tests but only ran 562. > > Whoops, that should be fixed now. Yup, it is. You're

Re: [RDBO] RDBO and computed columns

2008-02-05 Thread John Siracusa
On Feb 5, 2008 4:06 PM, Grzegorz Nosek <[EMAIL PROTECTED]> wrote: > t/db-objectok 1/566# Looks like you planned 566 > tests but only ran 562. Whoops, that should be fixed now. > sql_qualify_columns_on_load is on by default. Actually, it looks > hardcoded to one ($self->{..

Re: [RDBO] RDBO and computed columns

2008-02-05 Thread Grzegorz Nosek
On Mon, Feb 04, 2008 at 04:37:11PM -0500, John Siracusa wrote: > 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

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

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

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

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 t

Re: [RDBO] RDBO and computed columns

2008-02-03 Thread John Siracusa
On Feb 3, 2008 5:07 PM, Grzegorz Nosek <[EMAIL PROTECTED]> wrote: > __PACKAGE__ > ->meta->column('is_even') > ->add_trigger('on_set', > sub { > unset_column_value_modified( $_[0], 'is_even' ) > }); > > R::DB::O::Util is imported earlier with :columns

Re: [RDBO] RDBO and computed columns

2008-02-03 Thread Grzegorz Nosek
On Sun, Feb 03, 2008 at 04:21:26PM -0500, John Siracusa wrote: > On Feb 3, 2008 3:59 PM, Grzegorz Nosek <[EMAIL PROTECTED]> wrote: > > my ($a_foo) = @{ Foo::Manager->get_objects( query => [ id => 5, is_even => > > 0 ] ) }; > > $a_foo->v2( 5 ); > > $a_foo->save( changes_only => 1 ); > > > > After e

Re: [RDBO] RDBO and computed columns

2008-02-03 Thread John Siracusa
On Feb 3, 2008 3:59 PM, Grzegorz Nosek <[EMAIL PROTECTED]> wrote: > However, the problem arises after calling: > > my ($a_foo) = @{ Foo::Manager->get_objects( query => [ id => 5, is_even => 0 > ] ) }; > $a_foo->v2( 5 ); > $a_foo->save( changes_only => 1 ); > > The is_even condition is a result of

[RDBO] RDBO and computed columns

2008-02-03 Thread Grzegorz Nosek
Hi all, Consider a table with a row function attached (in PostgreSQL), e.g.: CREATE TABLE foo (id serial PRIMARY KEY, value int not null, v2 int not null); CREATE FUNCTION is_even(foo) RETURNS boolean STABLE STRICT AS $$ SELECT $1.value %2 = 0; $$ LANGUAGE SQL; (modulo t