Re: [RDBO] Sequence Support

2007-03-20 Thread Jonathan Vanasco

On Mar 20, 2007, at 7:02 PM, Jud wrote:

> On 20/03/07 18:57 -0400, Jonathan Vanasco <[EMAIL PROTECTED]> wrote:
>> ok.  its on my list right after the debugger module :)
>
> If you're actually putting together a debug module, I'd put in a  
> request
> for a simple way to turn on all debugging in Rose... Like via an
> environment variable, or using Log::Log4perl, etc...

a lot of stuff like that already exists
just about every rose class has

our $Debug= 0;

ie:

 $Rose::DB::Object::Manager::Debug= 1

will print a lot of neat stuff to stderr.

i've just been sketching out a customized debug class, so objects can  
inherit from it and have internal debugging.

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Sequence Support

2007-03-20 Thread Jud
On 20/03/07 18:57 -0400, Jonathan Vanasco <[EMAIL PROTECTED]> wrote:
> ok.  its on my list right after the debugger module :)

If you're actually putting together a debug module, I'd put in a request
for a simple way to turn on all debugging in Rose... Like via an
environment variable, or using Log::Log4perl, etc...



-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Sequence Support

2007-03-20 Thread Jonathan Vanasco

On Mar 20, 2007, at 3:27 PM, John Siracusa wrote:

> Well then code it up and send it to me :)

ok.  its on my list right after the debugger module :)

> That level abstraction is
> not strictly necessary to support the proposed feature (columns that
> are not part of the PK but that have default values pulled from
> sequences), but it might be useful nonetheless.

right -- but if you're handling a large db with a lot of inter- 
related tables, being able to access sequences directly is really  
helpful.


>> getting that to work with all dbs might be a pain though.
>
> Not really.  If you decide to do it, you'd delegate all db-specific
> functionality to the "db" (Rose::DB) object.  As mentioned earlier in
> this thread, there's already a vaguely cross-db-compatible
> next_value_in_sequence() method in Rose::DB.  You'd just have to add
> more such methods.  The Rose::DB::Sequence class wouldn't have any
> db-specific code in it at all.

well yes, but there would need to be a lot of conditionals in that  
module / the db specific drivers to implement the operations.  i'll  
still have to write them somewhere.


// Jonathan Vanasco

| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -
| SyndiClick.com
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -
|  FindMeOn.com - The cure for Multiple Web Personality Disorder
|  Web Identity Management and 3D Social Networking
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -
|  RoadSound.com - Tools For Bands, Stuff For Fans
|  Collaborative Online Management And Syndication Tools
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -



-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Sequence Support

2007-03-20 Thread John Siracusa
On 3/20/07, Jonathan Vanasco <[EMAIL PROTECTED]> wrote:
> I'd actually like to see sequence classes
> Rose::DB::Object::Metadata::Sequence
>
> Which lets us map sequences to rose objects , and vice versa
>
> I'd like to be able to call
>
> my $seq= MyApp::Rose::DB::Object::Sequence1->new();
> my $curval= $seq->curval;
> my $nextval= $seq->nextval;
> my $lastval = $seq->lastval;

Well then code it up and send it to me :)  That level abstraction is
not strictly necessary to support the proposed feature (columns that
are not part of the PK but that have default values pulled from
sequences), but it might be useful nonetheless.

> getting that to work with all dbs might be a pain though.

Not really.  If you decide to do it, you'd delegate all db-specific
functionality to the "db" (Rose::DB) object.  As mentioned earlier in
this thread, there's already a vaguely cross-db-compatible
next_value_in_sequence() method in Rose::DB.  You'd just have to add
more such methods.  The Rose::DB::Sequence class wouldn't have any
db-specific code in it at all.

-John

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Sequence Support

2007-03-20 Thread Jeff Chimene
Derek Watson wrote:
>
> Hello,
>
> Is it possible to get sequence support in RDBO? I know that sequences
> are supported for primary key generation, but I have a few cases where
> they are used for non-keyed columns, and I find myself writing (and
> re-writing) this into my classes:
>
> sub insert {
>
>   my $self = shift;
>
>   unless ($self->some_sequence_column) {
>
> $self->some_sequence_column($self->db->next_value_in_sequence('some_seq'));
>   }
>
>   return $self->SUPER::insert(@_);
> }
>
> But since next_value_in_sequence is not documented, I am worrying that
> it's interface may change or disappear.  Please correct me if I have
> missed something.
>
> Derek
Here's a perspective on sequences from the best database you never heard of:
http://www.oracle.com/technology/products/rdb/pdf/0307_sequences.pdf

Cheers,
jec

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Sequence Support

2007-03-20 Thread Jonathan Vanasco

On Mar 20, 2007, at 12:48 PM, John Siracusa wrote:

> On 3/20/07, Derek Watson <[EMAIL PROTECTED]> wrote:
>> Is it possible to get sequence support in RDBO? I know that  
>> sequences are
>> supported for primary key generation, but I have a few cases where  
>> they are
>> used for non-keyed columns
>
> What would this support look like?  How would the sequence be
> specified, and how would it behave on insert, update, etc.?
>
>> But since next_value_in_sequence is not documented, I am worrying  
>> that it's
>> interface may change or disappear.
>
> It almost certainly won't disappear and may become part of the public
> API eventually.
>
> -John


I'll second wanting support too :)

On Mar 20, 2007, at 1:11 PM, Derek Watson wrote:
> I suppose my use of serial/sequence columns is too specific to  
> bother adding to the API, but basically
>
> some_seq_column => { type => 'serial', not_null => 1, sequence =>  
> 'some_seq' },

That makes perfect sense to me.  although that looks like what is in  
there for oracle already

I'd actually like to see sequence classes
Rose::DB::Object::Metadata::Sequence

Which lets us map sequences to rose objects , and vice versa

I'd like to be able to call

my $seq= MyApp::Rose::DB::Object::Sequence1->new();
my $curval= $seq->curval;
my $nextval= $seq->nextval;
my $lastval = $seq->lastval;

getting that to work with all dbs might be a pain though.

I'll chime in with the Postgres compatibility -- if anyone wants this  
support too, please comment on  MySQL , SQLite, Oracle, etc

Postgres:
Create Sequence
http://www.postgresql.org/docs/8.2/interactive/sql-createsequence.html
Compatibility

CREATE SEQUENCE conforms to the SQL standard, with the 
following  
exceptions:

The standard's AS  expression is not 
supported.

Obtaining the next value is done using the nextval() 
function  
instead of the standard's NEXT VALUE FOR expression.
The OWNED BY clause is a PostgreSQL extension.

Alter Sequence
http://www.postgresql.org/docs/8.2/interactive/sql-altersequence.html
Compatibility

ALTER SEQUENCE conforms to the SQL standard, except for the 
OWNED  
BY and SET SCHEMA clauses, which are PostgreSQL extensions.



Drop Sequence

http://www.postgresql.org/docs/8.2/interactive/sql-dropsequence.html

Compatibility

DROP SEQUENCE conforms to the SQL standard, except that the  
standard only allows one sequence to be dropped per command, and  
apart from the IF EXISTS option, which is a PostgreSQL extension.



Sequence Manipulation Functions

http://www.postgresql.org/docs/8.2/interactive/functions-sequence.html

currval(regclass)   bigint  Return value most recently 
obtained with  
nextval for specified sequence
nextval(regclass)   bigint  Advance sequence and return new 
value
setval(regclass, bigint) bigint Set sequence's current value
setval(regclass, bigint, boolean) bigintSet sequence's 
current  
value and is_called flag

lastval - Return the value most recently returned by nextval in 
the  
current session. This function is identical to currval, except that  
instead of taking the sequence name as an argument it fetches the  
value of the last sequence that nextval was used on in the current  
session. It is an error to call lastval if nextval has not yet been  
called in the current session.

Important: To avoid blocking of concurrent transactions that 
obtain  
numbers from the same sequence, a nextval operation is never rolled  
back; that is, once a value has been fetched it is considered used,  
even if the transaction that did the nextval later aborts. This means  
that aborted transactions may leave unused "holes" in the sequence of  
assigned values. setval operations are never rolled back, either.
















// Jonathan Vanasco

| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -
| SyndiClick.com
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -
|  FindMeOn.com - The cure for Multiple Web Personality Disorder
|  Web Identity Management and 3D Social Networking
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -
|  RoadSound.com - Tools For Bands, Stuff For Fans
|  Collaborative Online Management And Syndication Tools
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -



-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net'

Re: [RDBO] Sequence Support

2007-03-20 Thread Derek Watson

What would this support look like?  How would the sequence be
specified, and how would it behave on insert, update, etc.?



I suppose my use of serial/sequence columns is too specific to bother adding
to the API, but basically

some_seq_column => { type => 'serial', not_null => 1, sequence => 'some_seq'
},

would use nextval('some_seq') on save if that column is missing. Similar to
the primary key generation that happens already.


But since next_value_in_sequence is not documented, I am worrying that
it's
> interface may change or disappear.

It almost certainly won't disappear and may become part of the public
API eventually.



Fantastic-- that's really all I need. Thanks for all the great work.

Derek
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Sequence Support

2007-03-20 Thread John Siracusa
On 3/20/07, Derek Watson <[EMAIL PROTECTED]> wrote:
> Is it possible to get sequence support in RDBO? I know that sequences are
> supported for primary key generation, but I have a few cases where they are
> used for non-keyed columns

What would this support look like?  How would the sequence be
specified, and how would it behave on insert, update, etc.?

> But since next_value_in_sequence is not documented, I am worrying that it's
> interface may change or disappear.

It almost certainly won't disappear and may become part of the public
API eventually.

-John

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object