Permalink
Browse files

Fixing Fixture generation task to be more compatible with SqlSrv

  • Loading branch information...
1 parent 9f85e24 commit 41603cacb799277930c5832c38f83440832f9625 @lorenzo lorenzo committed Jun 20, 2011
@@ -386,19 +386,23 @@ protected function _makeRecordString($records) {
protected function _getRecordsFromTable($modelName, $useTable = null) {
if ($this->interactive) {
$condition = null;
- $prompt = __d('cake_console', "Please provide a SQL fragment to use as conditions\nExample: WHERE 1=1 LIMIT 10");
+ $prompt = __d('cake_console', "Please provide a SQL fragment to use as conditions\nExample: WHERE 1=1");
while (!$condition) {
- $condition = $this->in($prompt, null, 'WHERE 1=1 LIMIT 10');
+ $condition = $this->in($prompt, null, 'WHERE 1=1');
}
+ $prompt = __d('cake_console', "How many records do you want to import?");
+ $recordCount = $this->in($prompt, null, 10);
} else {
- $condition = 'WHERE 1=1 LIMIT ' . (isset($this->params['count']) ? $this->params['count'] : 10);
+ $condition = 'WHERE 1=1';
+ $recordCount = (isset($this->params['count']) ? $this->params['count'] : 10);
}
$modelObject = new Model(array('name' => $modelName, 'table' => $useTable, 'ds' => $this->connection));
$records = $modelObject->find('all', array(
'conditions' => $condition,
- 'recursive' => -1
+ 'recursive' => -1,
+ 'limit' => $recordCount
));
- $db = ConnectionManager::getDataSource($modelObject->useDbConfig);
+ $db = $modelObject->getDatasource();
$schema = $modelObject->schema(true);
$out = array();
foreach ($records as $record) {
@@ -137,7 +137,7 @@ public function testImportOptionsTable() {
public function testImportRecordsFromDatabaseWithConditionsPoo() {
$this->Task->interactive = true;
$this->Task->expects($this->at(0))->method('in')
- ->will($this->returnValue('WHERE 1=1 LIMIT 10'));
+ ->will($this->returnValue('WHERE 1=1'));
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';

0 comments on commit 41603ca

Please sign in to comment.