[Bast-commits] r3273 - in trunk/DBIx-Class-Journal/lib/DBIx/Class:
. Schema Schema/Journal/DB
castaway at dev.catalyst.perl.org
castaway at dev.catalyst.perl.org
Wed May 9 23:02:08 GMT 2007
Author: castaway
Date: 2007-05-09 23:02:07 +0100 (Wed, 09 May 2007)
New Revision: 3273
Modified:
trunk/DBIx-Class-Journal/lib/DBIx/Class/Journal.pm
trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal.pm
trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal/DB/AuditHistory.pm
trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal/DB/AuditLog.pm
trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal/DB/Change.pm
Log:
Yay, test passes!
Modified: trunk/DBIx-Class-Journal/lib/DBIx/Class/Journal.pm
===================================================================
--- trunk/DBIx-Class-Journal/lib/DBIx/Class/Journal.pm 2007-05-09 01:56:53 UTC (rev 3272)
+++ trunk/DBIx-Class-Journal/lib/DBIx/Class/Journal.pm 2007-05-09 22:02:07 UTC (rev 3273)
@@ -22,9 +22,15 @@
if($self->in_storage)
{
my $s_name = $self->result_source->source_name();
- print STDERR "Schema: ", ref($self->result_source->schema), "\n";
my $al = $self->result_source->schema->_journal_schema->resultset("${s_name}AuditLog");
+ my ($pri, $too_many) = map { $self->get_column($_)} $self->primary_columns;
+ if(defined $pri && defined $too_many)
+ {
+ $self->throw_exception( "More than one possible key found for auto-inc on ".ref $self );
+ }
+ $pri ||= \'NULL'; #'
$al->create({
+ ID => $pri,
# created => {
# changeset => $self->result_source->schema->_journal_schema->current_changeset(),
# },
Modified: trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal/DB/AuditHistory.pm
===================================================================
--- trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal/DB/AuditHistory.pm 2007-05-09 01:56:53 UTC (rev 3272)
+++ trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal/DB/AuditHistory.pm 2007-05-09 22:02:07 UTC (rev 3273)
@@ -13,6 +13,7 @@
sub new
{
my ($self, $data, @rest) = @_;
+ my $source = $data->{-result_source};
$data->{change} = {
# ID => \'DEFAULT',
Modified: trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal/DB/AuditLog.pm
===================================================================
--- trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal/DB/AuditLog.pm 2007-05-09 01:56:53 UTC (rev 3272)
+++ trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal/DB/AuditLog.pm 2007-05-09 22:02:07 UTC (rev 3273)
@@ -6,6 +6,7 @@
__PACKAGE__->add_columns(
ID => {
data_type => 'integer',
+# is_auto_increment => 1,
is_nullable => 0,
},
create_id => {
@@ -23,15 +24,17 @@
sub new
{
- my ($self, $data, $source, @rest) = @_;
+ my ($self, $data, @rest) = @_;
+ my $source = $data->{-result_source};
$data->{created} = {
# ID => \'DEFAULT',
+# ID => 1,
changeset_id => $source->schema->current_changeset,
%{$data->{created}},
};
- $self->next::method($data, $source, @rest);
+ $self->next::method($data, @rest);
}
1;
Modified: trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal/DB/Change.pm
===================================================================
--- trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal/DB/Change.pm 2007-05-09 01:56:53 UTC (rev 3272)
+++ trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal/DB/Change.pm 2007-05-09 22:02:07 UTC (rev 3273)
@@ -2,6 +2,7 @@
use base 'DBIx::Class';
+# __PACKAGE__->load_components(qw/Core/);
__PACKAGE__->load_components(qw/Ordered Core/);
__PACKAGE__->table('change');
@@ -28,6 +29,6 @@
__PACKAGE__->add_unique_constraint('setorder', [ qw/changeset_id order_in/ ]);
__PACKAGE__->belongs_to('changeset', 'DBIx::Class::Schema::Journal::DB::ChangeSet', 'changeset_id');
-__PACKAGE__->position_column('order_in');
-__PACKAGE__->grouping_column('changeset_id');
+ __PACKAGE__->position_column('order_in');
+ __PACKAGE__->grouping_column('changeset_id');
1;
Modified: trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal.pm
===================================================================
--- trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal.pm 2007-05-09 01:56:53 UTC (rev 3272)
+++ trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal.pm 2007-05-09 22:02:07 UTC (rev 3273)
@@ -18,7 +18,7 @@
sub exception_action
{
my $self = shift;
- print STDERR Carp::longmess;
+# print STDERR Carp::longmess;
$self->next::method(@_);
}
@@ -28,7 +28,7 @@
my $self = shift;
$self->next::method(@_);
- print STDERR join(":", $self->sources), "\n";
+# print STDERR join(":", $self->sources), "\n";
my $journal_schema = DBIx::Class::Schema::Journal::DB->connect(@{ $self->journal_connection || $self->storage->connect_info });
# print STDERR "conn", $journal_schema->storage->connect_info;
@@ -104,6 +104,8 @@
## Create a new changeset, then run $code as a transaction
my $cs = $self->_journal_schema->resultset('ChangeSet');
+
+ $self->txn_begin;
my $changeset = $cs->create({ ( $self->_journal_schema->current_user() ? ( user_id => $self->_journal_schema->current_user()) : () ),
# user_id => $self->_journal_schema->current_user(),
session_id => $self->_journal_schema->current_session(),
More information about the Bast-commits
mailing list