Permalink
Browse files

Access columns privately

  • Loading branch information...
1 parent 9f7c15c commit eeff2f7fd187eb9384c1728b50909828882b027e @vti committed Apr 28, 2012
Showing with 7 additions and 7 deletions.
  1. +7 −7 lib/ObjectDB.pm
View
@@ -208,7 +208,7 @@ sub create {
my $sql = ObjectDB::SQLBuilder->build(
'insert',
table => $self->meta->table,
- set => {map { $_ => $self->column($_) } $self->columns}
+ set => {map { $_ => $self->{_columns}->{$_} } $self->columns}
);
my $sth = $dbh->prepare($sql->to_string);
@@ -254,7 +254,7 @@ sub load {
die ref($self) . ": no primary or unique keys specified" unless @columns;
- $params{where} = [map { $_ => $self->get_column($_) } @columns];
+ $params{where} = [map { $_ => $self->{_columns}->{$_} } @columns];
my $dbh = $self->init_db;
@@ -285,13 +285,13 @@ sub update {
my %where;
foreach my $name ($self->columns) {
- $where{$name} = $self->get_column($name)
+ $where{$name} = $self->{_columns}->{$name}
if $self->meta->is_primary_key($name);
}
if (!keys %where) {
foreach my $name ($self->columns) {
- $where{$name} = $self->get_column($name)
+ $where{$name} = $self->{_columns}->{$name}
if $self->meta->is_unique_key($name);
}
}
@@ -302,7 +302,7 @@ sub update {
my $dbh = $self->init_db;
my @columns = grep { !$self->meta->is_primary_key($_) } $self->columns;
- my @values = map { $self->column($_) } @columns;
+ my @values = map { $self->{_columns}->{$_} } @columns;
my %set;
@set{@columns} = @values;
@@ -328,13 +328,13 @@ sub delete {
my %where;
foreach my $name ($self->columns) {
- $where{$name} = $self->get_column($name)
+ $where{$name} = $self->{_columns}->{$name}
if $self->meta->is_primary_key($name);
}
if (!keys %where) {
foreach my $name ($self->columns) {
- $where{$name} = $self->get_column($name)
+ $where{$name} = $self->{_columns}->{$name}
if $self->meta->is_unique_key($name);
}
}

0 comments on commit eeff2f7

Please sign in to comment.