[Rt-commit] r4054 - in Jifty-DBI/trunk: . lib/Jifty lib/Jifty/DBI
lib/Jifty/DBI/Filter lib/Jifty/DBI/Handle lib/Jifty/DBI/Record t
jesse at bestpractical.com
jesse at bestpractical.com
Tue Nov 8 16:14:25 EST 2005
Author: jesse
Date: Tue Nov 8 16:14:23 2005
New Revision: 4054
Modified:
Jifty-DBI/trunk/ (props changed)
Jifty-DBI/trunk/lib/Jifty/DBI.pm
Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm
Jifty-DBI/trunk/lib/Jifty/DBI/Filter/DateTime.pm
Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm
Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Oracle.pm
Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Pg.pm
Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm
Jifty-DBI/trunk/lib/Jifty/DBI/Record/Cachable.pm
Jifty-DBI/trunk/lib/Jifty/DBI/SchemaGenerator.pm
Jifty-DBI/trunk/t/01records.t
Log:
r18573 at truegrounds: jesse | 2005-11-08 15:37:47 -0500
* field became column, consistently
Modified: Jifty-DBI/trunk/lib/Jifty/DBI.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI.pm (original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI.pm Tue Nov 8 16:14:23 2005
@@ -143,7 +143,7 @@
Now that we have a populated object, we should do something with it! ::Record
automagically generates accessors and mutators for us, so all we need to do
is call the methods. accessors are named C<column>(), and Mutators are named
-C<set_field>($). On to the example, just appending this to the code from
+C<set_column>($). On to the example, just appending this to the code from
the last example.
@@ -169,7 +169,7 @@
The output will be:
- >> Immutable field
+ >> Immutable column
Currently Set<Field> updates the data in the database as soon as you call
it. In the future I hope to extend ::Record to better support transactional
@@ -177,7 +177,7 @@
Finally, adding a removing records from the database. ::Record provides a
Create method which simply takes a hash of key=>value pairs. The keys
-exactly map to database fields.
+exactly map to database columns.
## Get a new record object.
$s1 = Simple->new($handle);
Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm (original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm Tue Nov 8 16:14:23 2005
@@ -690,7 +690,7 @@
}
}
- my ( $Clause, $qualified_field );
+ my ( $Clause, $qualified_column );
#TODO: $args{'value'} should take an array of values and generate
# the proper where clause.
@@ -725,19 +725,19 @@
# }}}
- # Set this to the name of the field and the alias, unless we've been
+ # Set this to the name of the column and the alias, unless we've been
# handed a subclause name
- $qualified_field = $args{'alias'} . "." . $args{'column'};
+ $qualified_column = $args{'alias'} . "." . $args{'column'};
if ( $args{'subclause'} ) {
$Clause = $args{'subclause'};
}
else {
- $Clause = $qualified_field;
+ $Clause = $qualified_column;
}
- warn "$self->_generic_restriction qualified_field=$qualified_field\n"
+ warn "$self->_generic_restriction qualified_column=$qualified_column\n"
if ( $self->DEBUG );
my ($restriction);
@@ -763,14 +763,14 @@
{
unless ( $args{'case_sensitive'} || !$args{'quote_value'} ) {
- ( $qualified_field, $args{'operator'}, $args{'value'} )
+ ( $qualified_column, $args{'operator'}, $args{'value'} )
= $self->_handle->_make_clause_case_insensitive(
- $qualified_field, $args{'operator'}, $args{'value'} );
+ $qualified_column, $args{'operator'}, $args{'value'} );
}
}
- my $clause = "($qualified_field $args{'operator'} $args{'value'})";
+ my $clause = "($qualified_column $args{'operator'} $args{'value'})";
# Juju because this should come _AFTER_ the EA
my $prefix = "";
@@ -1370,15 +1370,15 @@
$self->column( column => $_ ) for @_;
}
-=head2 fields table
+=head2 columns_in_db table
-Return a list of fields in table, lowercased.
+Return a list of columns in table, lowercased.
TODO: Why are they lowercased?
=cut
-sub fields {
+sub columns_in_db {
my $self = shift;
my $table = shift;
@@ -1396,14 +1396,14 @@
};
}
-=head2 has_field { table => undef, column => undef }
+=head2 has_column { table => undef, column => undef }
-Returns true if table has field column.
+Returns true if table has column column.
Return false otherwise
=cut
-sub has_field {
+sub has_column {
my $self = shift;
my %args = (
column => undef,
@@ -1412,8 +1412,8 @@
);
my $table = $args{table} or die;
- my $field = $args{column} or die;
- return grep { $_ eq $field } $self->fields($table);
+ my $column = $args{column} or die;
+ return grep { $_ eq $column } $self->columns_in_db($table);
}
=head2 table [table]
Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Filter/DateTime.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Filter/DateTime.pm (original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Filter/DateTime.pm Tue Nov 8 16:14:23 2005
@@ -9,7 +9,7 @@
=head1 NAME
-Jifty::DBI::Filter::DateTime - DateTime object wrapper around date fields
+Jifty::DBI::Filter::DateTime - DateTime object wrapper around date columns
=head1 DESCRIPTION
Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm (original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm Tue Nov 8 16:14:23 2005
@@ -337,9 +337,9 @@
=head2 update_record_value
-Takes a hash with fields: Table, Column, Value PrimaryKeys, and
+Takes a hash with columns: Table, Column, Value PrimaryKeys, and
IsSQLFunction. Table, and Column should be obvious, Value is where you
-set the new value you want the column to have. The primary_keys field should
+set the new value you want the column to have. The primary_keys column should
be the lvalue of Jifty::DBI::Record::PrimaryKeys(). Finally
IsSQLFunction is set when the Value is a SQL function. For example, you
might have ('Value'=>'PASSWORD(string)'), by setting IsSQLFunction that
@@ -361,7 +361,7 @@
my $query = 'UPDATE ' . $args{'table'} . ' ';
$query .= 'SET ' . $args{'column'} . '=';
- ## Look and see if the field is being updated via a SQL function.
+ ## Look and see if the column is being updated via a SQL function.
if ( $args{'is_sql_function'} ) {
$query .= $args{'value'} . ' ';
}
@@ -605,7 +605,7 @@
=head2 _make_clause_case_insensitive column operator VALUE
-Takes a field, operator and value. performs the magic necessary to make
+Takes a column, operator and value. performs the magic necessary to make
your database treat this clause as case insensitive.
Returns a column operator value triple.
@@ -614,15 +614,15 @@
sub _make_clause_case_insensitive {
my $self = shift;
- my $field = shift;
+ my $column = shift;
my $operator = shift;
my $value = shift;
if ( $value !~ /^\d+$/ ) { # don't downcase integer values
- $field = "lower($field)";
+ $column = "lower($column)";
$value = lc($value);
}
- return ( $field, $operator, $value, undef );
+ return ( $column, $operator, $value, undef );
}
=head2 begin_transaction
Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Oracle.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Oracle.pm (original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Oracle.pm Tue Nov 8 16:14:23 2005
@@ -175,12 +175,12 @@
sub blob_params {
my $self = shift;
- my $field = shift;
+ my $column = shift;
#my $type = shift;
# Don't assign to key 'value' as it is defined later.
return (
- { ora_field => $field,
+ { ora_column => $column,
ora_type => ORA_CLOB,
}
);
Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Pg.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Pg.pm (original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Pg.pm Tue Nov 8 16:14:23 2005
@@ -115,7 +115,7 @@
=head2 _make_clause_case_insensitive column operator VALUE
-Takes a field, operator and value. performs the magic necessary to make
+Takes a column, operator and value. performs the magic necessary to make
your database treat this clause as case insensitive.
Returns a column operator value triple.
@@ -124,24 +124,24 @@
sub _make_clause_case_insensitive {
my $self = shift;
- my $field = shift;
+ my $column = shift;
my $operator = shift;
my $value = shift;
if ( $value =~ /^['"]?\d+['"]?$/ )
{ # we don't need to downcase numeric values
- return ( $field, $operator, $value );
+ return ( $column, $operator, $value );
}
if ( $operator =~ /LIKE/i ) {
$operator =~ s/LIKE/ILIKE/ig;
- return ( $field, $operator, $value );
+ return ( $column, $operator, $value );
}
elsif ( $operator =~ /=/ ) {
- return ( "LOWER($field)", $operator, $value, "LOWER(?)" );
+ return ( "LOWER($column)", $operator, $value, "LOWER(?)" );
}
else {
- $self->SUPER::_make_clause_case_insensitive( $field, $operator,
+ $self->SUPER::_make_clause_case_insensitive( $column, $operator,
$value );
}
}
Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm (original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm Tue Nov 8 16:14:23 2005
@@ -129,7 +129,7 @@
goto &$AUTOLOAD;
}
elsif ( $action eq 'write' ) {
- return ( 0, 'Immutable field' ) unless $column->writable;
+ return ( 0, 'Immutable column' ) unless $column->writable;
if ( UNIVERSAL::isa( $column->refers_to, "Jifty::DBI::Record" ) ) {
*{$AUTOLOAD} = sub {
@@ -368,7 +368,7 @@
=head2 __value
-Takes a field name and returns that field's value. Subclasses should
+Takes a column name and returns that column's value. Subclasses should
never override __value.
=cut
@@ -469,11 +469,6 @@
@_
);
- if ( $args{'field'} ) {
- Carp::cluck("field in ->set is deprecated");
- $args{'column'} = delete $args{'field'};
- }
-
my $ret = Class::ReturnValue->new();
my $column = $self->column( $args{'column'} );
@@ -584,7 +579,7 @@
sub _validate {
my $self = shift;
- my $field = shift;
+ my $column = shift;
my $value = shift;
#Check type of input
@@ -677,7 +672,7 @@
my %cols = ();
foreach ( @{ $self->_primary_keys } ) {
- return ( 0, "Missing PK field: '$_'" ) unless defined $data->{$_};
+ return ( 0, "Missing PK column: '$_'" ) unless defined $data->{$_};
$cols{$_} = $data->{$_};
}
return ( $self->load_by_cols(%cols) );
Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Record/Cachable.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Record/Cachable.pm (original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Record/Cachable.pm Tue Nov 8 16:14:23 2005
@@ -197,8 +197,8 @@
sub __Value {
my $self = shift;
- my $field = shift;
- return ( $self->SUPER::__value($field) );
+ my $column = shift;
+ return ( $self->SUPER::__value($column) );
}
# Function: _store
Modified: Jifty-DBI/trunk/lib/Jifty/DBI/SchemaGenerator.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/SchemaGenerator.pm (original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/SchemaGenerator.pm Tue Nov 8 16:14:23 2005
@@ -183,7 +183,7 @@
my $model = shift;
my $table_name = $model->table;
- my @columns = $model->columns;
+ my @columns = $model->columns_in_db;
my @cols;
Modified: Jifty-DBI/trunk/t/01records.t
==============================================================================
--- Jifty-DBI/trunk/t/01records.t (original)
+++ Jifty-DBI/trunk/t/01records.t Tue Nov 8 16:14:23 2005
@@ -36,8 +36,8 @@
# _accessible testings
is( $rec->_accessible('id' => 'read'), 1, 'id is accessible for read' );
is( $rec->_accessible('id' => 'write'), 0, 'id is not accessible for write' );
- is( $rec->_accessible('id'), undef, "any field is not accessible in undefined mode" );
- is( $rec->_accessible('unexpected_field' => 'read'), undef, "field doesn't exist and can't be accessible for read" );
+ is( $rec->_accessible('id'), undef, "any column is not accessible in undefined mode" );
+ is( $rec->_accessible('unexpected_column' => 'read'), undef, "column doesn't exist and can't be accessible for read" );
is_deeply( [sort($rec->readable_attributes)], [sort qw(employee_id id name phone)], 'readable attributes' );
is_deeply( [sort($rec->writable_attributes)], [sort qw(employee_id name phone)], 'writable attributes' );
@@ -56,21 +56,21 @@
ok($val, $msg) ;
is($rec->name, 'Obra', "We did actually change the name");
-# Validate immutability of the field id
+# Validate immutability of the column id
($val, $msg) = $rec->set_id( $rec->id + 1 );
ok(!$val, $msg);
- is($msg, 'Immutable field', 'id is immutable field');
+ is($msg, 'Immutable column', 'id is immutable column');
is($rec->id, $id, "The record still has its id");
-# Check some non existant field
- ok( !eval{ $rec->some_unexpected_field }, "The record has no 'some_unexpected_field'");
+# Check some non existant column
+ ok( !eval{ $rec->some_unexpected_column }, "The record has no 'some_unexpected_column'");
{
# test produce DBI warning
local $SIG{__WARN__} = sub {return};
- is( $rec->_value( 'some_unexpected_field' ), undef, "The record has no 'some_unexpected_field'");
+ is( $rec->_value( 'some_unexpected_column' ), undef, "The record has no 'some_unexpected_column'");
}
- ok (!eval { $rec->set_some_unexpected_field( 'foo' )}, "Can't call nonexistent fields");
- ($val, $msg) = $rec->_set(column =>'some_unexpected_field', value =>'foo');
+ ok (!eval { $rec->set_some_unexpected_column( 'foo' )}, "Can't call nonexistent columns");
+ ($val, $msg) = $rec->_set(column =>'some_unexpected_column', value =>'foo');
ok(!$val, "$msg");
@@ -104,8 +104,8 @@
$newrec = TestApp::Address->new($handle);
($val, $msg) = $newrec->_load_from_sql('SELECT id FROM addresses WHERE id = ?', $newid);
is($val, 1, 'found object');
- is($newrec->name, '12345678901234', "autoloaded not prefetched field");
- is($newrec->employee_id, '1234567890', "autoloaded not prefetched field");
+ is($newrec->name, '12345678901234', "autoloaded not prefetched column");
+ is($newrec->employee_id, '1234567890', "autoloaded not prefetched column");
# _load_from_sql and missing PK
$newrec = TestApp::Address->new($handle);
@@ -154,8 +154,8 @@
is( $newrec->id, $newid, "loaded correct record" );
$newrec = TestApp::Address->new($handle);
($val, $msg) = $newrec->load_by_primary_keys( phone => 'some' );
- ok( !$val, "couldn't load, missing PK field");
- is( $msg, "Missing PK field: 'id'", "right error message" );
+ ok( !$val, "couldn't load, missing PK column");
+ is( $msg, "Missing PK column: 'id'", "right error message" );
# load_by_cols and empty or NULL values
$rec = TestApp::Address->new($handle);
More information about the Rt-commit
mailing list