Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ private function insert($validate=true)
$column = $table->get_column_by_inflected_name($pk);

if ($column->auto_increment || $use_sequence)
$this->attributes[$pk] = static::connection()->insert_id($table->sequence);
$this->attributes[$pk] = $column->cast(static::connection()->insert_id($table->sequence), static::connection());
}

$this->__new_record = false;
Expand Down
12 changes: 12 additions & 0 deletions test/ActiveRecordWriteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,18 @@ public function test_dirty_attributes()
$this->assert_equals(array('name','special'),array_keys($book->dirty_attributes()));
}

public function test_id_type()
{
$book = new Book;
$book->save();

$bookFromFind = Book::find($book->id);

// both should be ints
$this->assert_same($book->id, $bookFromFind->id);
}


public function test_dirty_attributes_cleared_after_saving()
{
$book = $this->make_new_book_and();
Expand Down