Permalink
Browse files

Adapts all the tests to use `some_Date`. #188

  • Loading branch information...
1 parent 0cd6a77 commit ae4745054473868c4f220f1fe414cc2b9bf56297 @greut greut committed Apr 15, 2012
Showing with 15 additions and 13 deletions.
  1. +9 −7 lib/Model.php
  2. +4 −4 test/helpers/AdapterTest.php
  3. +1 −1 test/sql/pgsql.sql
  4. +1 −1 test/sql/sqlite.sql
View
@@ -436,15 +436,17 @@ public function __wakeup()
public function assign_attribute($name, $value)
{
$table = static::table();
- if (array_key_exists($name,$table->columns) && !is_object($value)){
- $value = $table->columns[$name]->cast($value,static::connection());
- }else{
- $col = $table->get_column_by_inflected_name($name);
- if (!is_null($col) && !is_object($value)){
- $value = $col->cast($value,static::connection());
+ if (!is_object($value)) {
+ if (array_key_exists($name, $table->columns)) {
+ $value = $table->columns[$name]->cast($value, static::connection());
+ } else {
+ $col = $table->get_column_by_inflected_name($name);
+ if (!is_null($col)){
+ $value = $col->cast($value, static::connection());
+ }
}
}
-
+
// convert php's \DateTime to ours
if ($value instanceof \DateTime)
$value = new DateTime($value->format('Y-m-d H:i:s T'));
@@ -112,9 +112,9 @@ public function test_date_time_type()
public function test_date()
{
$columns = $this->conn->columns('authors');
- $this->assert_equals('date',$columns['some_date']->raw_type);
- $this->assert_equals(Column::DATE,$columns['some_date']->type);
- $this->assert_true($columns['some_date']->length >= 7);
+ $this->assert_equals('date', $columns['some_Date']->raw_type);
+ $this->assert_equals(Column::DATE, $columns['some_Date']->type);
+ $this->assert_true($columns['some_Date']->length >= 7);
}
public function test_columns_no_inflection_on_hash_key()
@@ -258,7 +258,7 @@ public function test_escape()
public function test_columnsx()
{
$columns = $this->conn->columns('authors');
- $names = array('author_id','parent_author_id','name','updated_at','created_at','some_date','some_time','some_text','encrypted_password','mixedCaseField');
+ $names = array('author_id','parent_author_id','name','updated_at','created_at','some_Date','some_time','some_text','encrypted_password','mixedCaseField');
if ($this->conn instanceof ActiveRecord\OciAdapter)
$names = array_filter(array_map('strtolower',$names),function($s) { $s !== 'some_time'; });
View
@@ -4,7 +4,7 @@ CREATE TABLE authors(
name VARCHAR(25) NOT NULL DEFAULT 'default_name',
updated_at timestamp,
created_at timestamp,
- some_date date,
+ "some_Date" date,
some_time time,
some_text text,
encrypted_password varchar(50),
View
@@ -4,7 +4,7 @@ CREATE TABLE authors(
name VARCHAR (25) NOT NULL DEFAULT default_name, -- don't touch those spaces
updated_at datetime,
created_at datetime,
- some_date date,
+ some_Date date,
some_time time,
some_text text,
encrypted_password varchar(50),

0 comments on commit ae47450

Please sign in to comment.