[RDBO] One-to-many and aggregates

2007-10-24 Thread Arshavir Grigorian
Hi, I have two tables t1 and t2 linked through a one-to-many relationship. Each record in t1 has 0 or more corresponding records in t2. Given a My::T1 object, I would like to get an average on a column in t2 for all rows corresponding to the My::T1 row. t1 (id, name) --- 1, 'm

Re: [RDBO] Primary and unique keys

2007-10-24 Thread Arshavir Grigorian
Thank you. On 10/24/07, John Siracusa <[EMAIL PROTECTED]> wrote: > On 10/25/07 1:29 AM, Arshavir Grigorian wrote: > > Thanks. I guess I am not sure how the unique keys are named, > > http://search.cpan.org/~jsiracusa/Rose-DB-Object-0.765/lib/Rose/DB/Object/Me > tadata/UniqueKey.pm > > name [NAME]

Re: [RDBO] Primary and unique keys

2007-10-24 Thread John Siracusa
On 10/25/07 1:29 AM, Arshavir Grigorian wrote: > Thanks. I guess I am not sure how the unique keys are named, http://search.cpan.org/~jsiracusa/Rose-DB-Object-0.765/lib/Rose/DB/Object/Me tadata/UniqueKey.pm name [NAME] Get or set the name of the unique key. This name should be unique among all u

Re: [RDBO] Primary and unique keys

2007-10-24 Thread Arshavir Grigorian
On 10/24/07, John Siracusa <[EMAIL PROTECTED]> wrote: > On 10/25/07 12:45 AM, Arshavir Grigorian wrote: > > In my class definition, I have > > > > primary_key_columns => [ 'pk' ], > > unique_key => [ 'pk', 'col2' ], > > > > Since, I am accessing the data more often using the 2 column match, > > doe

Re: [RDBO] Primary and unique keys

2007-10-24 Thread John Siracusa
On 10/25/07 12:45 AM, Arshavir Grigorian wrote: > In my class definition, I have > > primary_key_columns => [ 'pk' ], > unique_key => [ 'pk', 'col2' ], > > Since, I am accessing the data more often using the 2 column match, > does it make sense to trick Rose into thinking that my primary key is >

[RDBO] Primary and unique keys

2007-10-24 Thread Arshavir Grigorian
Hi, I have a table with a single column primary key. However, in certain situations, I would like to access a row by matching both the primary key and another column on that table. The two form a unique key. I am wondering whether I can use the new() method to do both My::Table->new(pk => 1) AND

Re: [RDBO] Date formatting

2007-10-24 Thread Arshavir Grigorian
The first actually returned an array reference, but the second worked just fine. Thank you. On 10/24/07, Cees Hek <[EMAIL PROTECTED]> wrote: > On 10/25/07, Arshavir Grigorian <[EMAIL PROTECTED]> wrote: > > Hi, > > > > I am having trouble formatting dates in Template Toolkit. > > > > $file->creat

Re: [RDBO] Date formatting

2007-10-24 Thread Cees Hek
On 10/25/07, Arshavir Grigorian <[EMAIL PROTECTED]> wrote: > Hi, > > I am having trouble formatting dates in Template Toolkit. > > $file->create_dt(format => '%m/%d/%Y %H:%M:%S') - works fine. > > But > > [% file.create_dt(format => '%m/%d/%Y %H:%M:%S') %] or > [% file.create_dt.format('%m/%d/%Y %H

[RDBO] Date formatting

2007-10-24 Thread Arshavir Grigorian
Hi, I am having trouble formatting dates in Template Toolkit. $file->create_dt(format => '%m/%d/%Y %H:%M:%S') - works fine. But [% file.create_dt(format => '%m/%d/%Y %H:%M:%S') %] or [% file.create_dt.format('%m/%d/%Y %H:%M:%S') %] do not. Any ideas how to do this? I also tried TT's date plugin

Re: [RDBO] Identity of Rose::DB::Object::Cached derived objects

2007-10-24 Thread John Siracusa
On 10/18/07 5:03 PM, Lamprecht wrote: > while I'm doing my first steps into Rose::DB, I face the following problem: > I am looking for a way to maintain identity of Rose::DB::Object > instances, that share the same PK. ( Represent the same row ). > > I hoped deriving from Rose::DB::Object::Cached

Re: [RDBO] sqlite serial column type

2007-10-24 Thread Peter Karman
On 10/24/2007 11:06 AM, John Siracusa wrote: > On 10/24/07 11:59 AM, Peter Karman wrote: >> True. Although AFAIK, sqlite actually stores everything but the PK as a char >> string and ignores the data type. So if you had an autoincrementing column >> that wasn't the PK, it wouldn't strictly be an

Re: [RDBO] sqlite serial column type

2007-10-24 Thread John Siracusa
On 10/24/07 11:59 AM, Peter Karman wrote: > True. Although AFAIK, sqlite actually stores everything but the PK as a char > string and ignores the data type. So if you had an autoincrementing column > that wasn't the PK, it wouldn't strictly be an integer but it would be serial. RDBO's "serial" col

Re: [RDBO] sqlite serial column type

2007-10-24 Thread Peter Karman
On 10/24/2007 10:50 AM, John Siracusa wrote: > What it doesn't do, as you noticed, is set the column type to "serial". > Instead, it uses "integer." Technically, this is a more accurate reflection > of the SQLite data type. Functionally, it does not prevent the column from > working as expecte

Re: [RDBO] sqlite serial column type

2007-10-24 Thread John Siracusa
On 10/24/07 11:03 AM, Peter Karman wrote: > The RDBO docs claim that: > > CREATE TABLE mytable > ( > id INTEGER PRIMARY KEY AUTOINCREMENT, > ... > ); > > is the supported syntax for auto-detecting a serial column in SQLite. The test > case below fails to prove this out h

[RDBO] sqlite serial column type

2007-10-24 Thread Peter Karman
The RDBO docs claim that: CREATE TABLE mytable ( id INTEGER PRIMARY KEY AUTOINCREMENT, ... ); is the supported syntax for auto-detecting a serial column in SQLite. The test case below fails to prove this out however. I'd love to know if the test is wrong, or something i