[Bast-commits] r4673 - in trunk/DBIx-Class-Journal/lib/DBIx/Class: . Schema/Journal Schema/Journal/DB

nothingmuch at dev.catalyst.perl.org nothingmuch at dev.catalyst.perl.org
Wed Jul 30 04:47:28 BST 2008


Author: nothingmuch
Date: 2008-07-30 04:47:27 +0100 (Wed, 30 Jul 2008)
New Revision: 4673

Added:
   trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal/DB/ChangeLog.pm
Removed:
   trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal/DB/Change.pm
Modified:
   trunk/DBIx-Class-Journal/lib/DBIx/Class/Journal.pm
   trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal/DB.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
Log:
rename Change to ChangeLog to avoid reserved word problem

Modified: trunk/DBIx-Class-Journal/lib/DBIx/Class/Journal.pm
===================================================================
--- trunk/DBIx-Class-Journal/lib/DBIx/Class/Journal.pm	2008-07-29 21:31:41 UTC (rev 4672)
+++ trunk/DBIx-Class-Journal/lib/DBIx/Class/Journal.pm	2008-07-30 03:47:27 UTC (rev 4673)
@@ -69,8 +69,8 @@
             $self->throw_exception( "No audit_log entry found for ".ref($self) . " item $pri" ) if(!$alentry);
              
             ## bulk_update doesnt do "create new item on update of rel-accessor with hashref, yet
-            my $change = $self->result_source->schema->_journal_schema->resultset('Change')->create({ changeset_id => $self->result_source->schema->_journal_schema->current_changeset });
-            $alentry->delete_id($change->ID);
+            my $change = $self->result_source->schema->_journal_schema->resultset('ChangeLog')->create({ changeset_id => $self->result_source->schema->_journal_schema->current_changeset });
+            $alentry->delete_id($change->id);
             $alentry->update();
         }
     }

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	2008-07-29 21:31:41 UTC (rev 4672)
+++ trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal/DB/AuditHistory.pm	2008-07-30 03:47:27 UTC (rev 4673)
@@ -8,7 +8,7 @@
                                data_type => 'integer',
                                is_nullable => 0,
                            });
-__PACKAGE__->belongs_to('change', 'DBIx::Class::Schema::Journal::DB::Change', 'change_id');
+__PACKAGE__->belongs_to('change', 'DBIx::Class::Schema::Journal::DB::ChangeLog', 'change_id');
 
 sub new
 {

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	2008-07-29 21:31:41 UTC (rev 4672)
+++ trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal/DB/AuditLog.pm	2008-07-30 03:47:27 UTC (rev 4673)
@@ -21,8 +21,8 @@
                            });
 __PACKAGE__->set_primary_key('ID');
 
-  __PACKAGE__->belongs_to('created', 'DBIx::Class::Schema::Journal::DB::Change', 'create_id');
-  __PACKAGE__->belongs_to('deleted', 'DBIx::Class::Schema::Journal::DB::Change', 'delete_id');
+  __PACKAGE__->belongs_to('created', 'DBIx::Class::Schema::Journal::DB::ChangeLog', 'create_id');
+  __PACKAGE__->belongs_to('deleted', 'DBIx::Class::Schema::Journal::DB::ChangeLog', 'delete_id');
 
 sub new
 {

Deleted: trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal/DB/Change.pm
===================================================================
--- trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal/DB/Change.pm	2008-07-29 21:31:41 UTC (rev 4672)
+++ trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal/DB/Change.pm	2008-07-30 03:47:27 UTC (rev 4673)
@@ -1,34 +0,0 @@
-package DBIx::Class::Schema::Journal::DB::Change;
-
-use base 'DBIx::Class';
-
-# __PACKAGE__->load_components(qw/Core/);
-__PACKAGE__->load_components(qw/Ordered Core/);
-__PACKAGE__->table('change');
-
-__PACKAGE__->add_columns(
-                         ID => {
-                             data_type => 'integer',
-                             is_auto_increment => 1,
-                             is_primary_key => 1,
-                             is_nullable => 0,
-                         },
-                         changeset_id => {
-                             data_type => 'integer',
-                             is_nullable => 0,
-                             is_foreign_key => 1,
-                         },
-                         order_in => {
-                             data_type => 'integer',
-                             is_nullable => 0,
-                         },
-                         );
-
-
-__PACKAGE__->set_primary_key('ID');
-__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');
-1;

Copied: trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal/DB/ChangeLog.pm (from rev 3273, trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal/DB/Change.pm)
===================================================================
--- trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal/DB/ChangeLog.pm	                        (rev 0)
+++ trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal/DB/ChangeLog.pm	2008-07-30 03:47:27 UTC (rev 4673)
@@ -0,0 +1,34 @@
+package DBIx::Class::Schema::Journal::DB::ChangeLog;
+
+use base 'DBIx::Class';
+
+# __PACKAGE__->load_components(qw/Core/);
+__PACKAGE__->load_components(qw/Ordered Core/);
+__PACKAGE__->table('change_log');
+
+__PACKAGE__->add_columns(
+                         id => {
+                             data_type => 'integer',
+                             is_auto_increment => 1,
+                             is_primary_key => 1,
+                             is_nullable => 0,
+                         },
+                         changeset_id => {
+                             data_type => 'integer',
+                             is_nullable => 0,
+                             is_foreign_key => 1,
+                         },
+                         order_in => {
+                             data_type => 'integer',
+                             is_nullable => 0,
+                         },
+                         );
+
+
+__PACKAGE__->set_primary_key('id');
+__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');
+1;

Modified: trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal/DB.pm
===================================================================
--- trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal/DB.pm	2008-07-29 21:31:41 UTC (rev 4672)
+++ trunk/DBIx-Class-Journal/lib/DBIx/Class/Schema/Journal/DB.pm	2008-07-30 03:47:27 UTC (rev 4673)
@@ -7,24 +7,33 @@
 __PACKAGE__->mk_group_accessors( simple => 'current_session' );
 __PACKAGE__->mk_group_accessors( simple => '_current_changeset_container' );
 
+DBIx::Class::Schema::Journal::DB->load_classes(qw/
+                                               ChangeSet
+                                               ChangeLog
+                                               AuditLog
+                                               AuditHistory
+                                               /);
+
+
+sub _current_changeset {
+    my $self = shift;
+    my $ref = $self->_current_changeset_container;
+    $ref && $ref->{changeset};
+}
+
 # this is for localization of the current changeset
 sub current_changeset {
     my ( $self, @args ) = @_;
 
-    $self->throw_error("setting current_changeset is not supported, use txn_do to create a new changeset") if @args;
+    $self->throw_exception("setting current_changeset is not supported, use txn_do to create a new changeset") if @args;
 
-    my $ref = $self->_current_changeset_container;
+    my $id = $self->_current_changeset;
 
-    return $ref && $ref->{changeset};
+    $self->throw_exception("Can't call current_changeset outside of a transaction") unless $id;
+
+    return $id;
 }
 
-DBIx::Class::Schema::Journal::DB->load_classes(qw/
-                                               ChangeSet
-                                               Change
-                                               AuditLog
-                                               AuditHistory
-                                               /);
-
 sub journal_create_changeset {
     my ( $self, @args ) = @_;
 




More information about the Bast-commits mailing list