From: Yuval Kogman Date: Wed, 30 Jul 2008 03:47:27 +0000 (+0000) Subject: rename Change to ChangeLog to avoid reserved word problem X-Git-Tag: v0.900201~88 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fd45c47654aec53a2d8351106f67bc5265441515;p=dbsrgits%2FDBIx-Class-Journal.git rename Change to ChangeLog to avoid reserved word problem --- diff --git a/lib/DBIx/Class/Journal.pm b/lib/DBIx/Class/Journal.pm index b93987c..8c3a57d 100644 --- a/lib/DBIx/Class/Journal.pm +++ b/lib/DBIx/Class/Journal.pm @@ -69,8 +69,8 @@ sub delete $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(); } } diff --git a/lib/DBIx/Class/Schema/Journal/DB.pm b/lib/DBIx/Class/Schema/Journal/DB.pm index 4f31cb1..1f247fb 100644 --- a/lib/DBIx/Class/Schema/Journal/DB.pm +++ b/lib/DBIx/Class/Schema/Journal/DB.pm @@ -7,23 +7,32 @@ __PACKAGE__->mk_group_accessors( simple => 'current_user' ); __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; -DBIx::Class::Schema::Journal::DB->load_classes(qw/ - ChangeSet - Change - AuditLog - AuditHistory - /); + return $id; +} sub journal_create_changeset { my ( $self, @args ) = @_; diff --git a/lib/DBIx/Class/Schema/Journal/DB/AuditHistory.pm b/lib/DBIx/Class/Schema/Journal/DB/AuditHistory.pm index dbfacf1..d19d11b 100644 --- a/lib/DBIx/Class/Schema/Journal/DB/AuditHistory.pm +++ b/lib/DBIx/Class/Schema/Journal/DB/AuditHistory.pm @@ -8,7 +8,7 @@ __PACKAGE__->add_columns( 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 { diff --git a/lib/DBIx/Class/Schema/Journal/DB/AuditLog.pm b/lib/DBIx/Class/Schema/Journal/DB/AuditLog.pm index a28af3d..8938045 100644 --- a/lib/DBIx/Class/Schema/Journal/DB/AuditLog.pm +++ b/lib/DBIx/Class/Schema/Journal/DB/AuditLog.pm @@ -21,8 +21,8 @@ __PACKAGE__->add_columns( }); __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 { diff --git a/lib/DBIx/Class/Schema/Journal/DB/Change.pm b/lib/DBIx/Class/Schema/Journal/DB/ChangeLog.pm similarity index 87% rename from lib/DBIx/Class/Schema/Journal/DB/Change.pm rename to lib/DBIx/Class/Schema/Journal/DB/ChangeLog.pm index 519973a..d3ed0ef 100644 --- a/lib/DBIx/Class/Schema/Journal/DB/Change.pm +++ b/lib/DBIx/Class/Schema/Journal/DB/ChangeLog.pm @@ -1,13 +1,13 @@ -package DBIx::Class::Schema::Journal::DB::Change; +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'); +__PACKAGE__->table('change_log'); __PACKAGE__->add_columns( - ID => { + id => { data_type => 'integer', is_auto_increment => 1, is_primary_key => 1, @@ -25,7 +25,7 @@ __PACKAGE__->add_columns( ); -__PACKAGE__->set_primary_key('ID'); +__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');