Skip to content

Commit

Permalink
- adding test counts
Browse files Browse the repository at this point in the history
- making select behave like the others, and require columns passed in
  • Loading branch information
Stevan Little committed Mar 27, 2009
1 parent 37155a6 commit 7a7796e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 49 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1 +1,2 @@
foo
foo
.DS_Store
52 changes: 9 additions & 43 deletions lib/FeyX/Active/Table.pm
Expand Up @@ -11,79 +11,45 @@ use FeyX::Active::SQL::Delete;

extends 'Fey::Table';

#
# ->select => all columns
# ->select('*') => all columns
# ->select(
# 'foo',
# 'bar',
# 'baz'
# ) => foo bar baz columns
#

sub select {
my ($self, @names) = @_;

my $self = shift;
my $select = FeyX::Active::SQL::Select->new(
dbh => $self->schema->dbi_manager->default_source->dbh
);

if (scalar @names == 0 || (scalar @names == 1 && $names[0] eq '*')) {
$select->select( $self );
}
else {
$select->select( $self->columns( @names ) );
}

# NOTE:
# this can be called later
# and overwritten without
# issue (so say the Fey docs)
# - SL
$select->from( $self );
$select->from( $self );
$select->select( @_ ? @_ : $self );
$select;
}

#
# ->delete
#

sub delete {
my $self = shift;
my $self = shift;
my $delete = FeyX::Active::SQL::Delete->new(
dbh => $self->schema->dbi_manager->default_source->dbh
);

$delete->from($self);
$delete->from( $self );
$delete;
}

#
# ->insert( foo => 'FOO', bar => $bar, baz => Baz->new )
#

sub insert {
my $self = shift;
my $self = shift;
my $insert = FeyX::Active::SQL::Insert->new(
dbh => $self->schema->dbi_manager->default_source->dbh
);

$insert->into($self);
$insert->into( $self );
$insert->values( @_ ) if @_;
$insert;
}

#
# ->update( foo => 'FOO', baz => Baz->new )
#

sub update {
my $self = shift;
my $self = shift;
my $update = FeyX::Active::SQL::Update->new(
dbh => $self->schema->dbi_manager->default_source->dbh
);

$update->update($self);
$update->update( $self );
$update->set( @_ ) if @_;
$update;
}
Expand Down
12 changes: 9 additions & 3 deletions t/000_load.t
Expand Up @@ -3,11 +3,17 @@
use strict;
use warnings;

use Test::More 'no_plan';
use Test::More tests => 7;
use Test::Exception;

BEGIN {
use_ok('FeyX::Active::Table');
}
use_ok('FeyX::Active::Schema');
use_ok('FeyX::Active::Table');

use_ok('FeyX::Active::SQL');
use_ok('FeyX::Active::SQL::Select');
use_ok('FeyX::Active::SQL::Update');
use_ok('FeyX::Active::SQL::Delete');
use_ok('FeyX::Active::SQL::Insert');
}

5 changes: 3 additions & 2 deletions t/001_basic.t
Expand Up @@ -3,7 +3,7 @@
use strict;
use warnings;

use Test::More 'no_plan';
use Test::More tests => 27;
use Test::Exception;

use Fey;
Expand Down Expand Up @@ -115,7 +115,8 @@ foreach my $person (@people) {

{

my $select = $Person->select('last_name')->where( $Person->column('first_name'), '==', 'Homer');
my $select = $Person->select( $Person->column('last_name') )
->where( $Person->column('first_name'), '==', 'Homer');
isa_ok($select, 'FeyX::Active::SQL::Select');
{
my $sth = $select->execute;
Expand Down

0 comments on commit 7a7796e

Please sign in to comment.