Skip to content

Commit

Permalink
Make writing of records type-sensitive, so null-values and numeric va…
Browse files Browse the repository at this point in the history
…lues are correctly written to the fixture.
  • Loading branch information
ctavan authored and felixge committed Jan 31, 2011
1 parent 5d79cc9 commit d931d28
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cakephp/shells/fixturize/fixturize.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,13 @@ function main() {
$record[$name]['id'] = String::uuid();
}
foreach ($record[$name] as $field => $val) {
$out[] = sprintf(' \'%s\' => \'%s\',', addcslashes($field, "'"), addcslashes($val, "'"));
if (is_null($val)) {
$out[] = sprintf(' \'%s\' => null,', addcslashes($field, "'"));
} else if (is_numeric($val)) {
$out[] = sprintf(' \'%s\' => %s,', addcslashes($field, "'"), $val);
} else {
$out[] = sprintf(' \'%s\' => \'%s\',', addcslashes($field, "'"), addcslashes($val, "'"));
}
}
$out[] = ' ),';
}
Expand Down

0 comments on commit d931d28

Please sign in to comment.