Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run fixture/load User fails to load User data #172

Closed
sdlins opened this issue Jun 12, 2016 · 10 comments
Closed

Run fixture/load User fails to load User data #172

sdlins opened this issue Jun 12, 2016 · 10 comments
Milestone

Comments

@sdlins
Copy link
Contributor

sdlins commented Jun 12, 2016

What steps will reproduce the problem?

Execute php yii fixture/load User;

What's expected?

Data from tests\codeception\common\fixtures\data\init_login.php should be loaded to db;

What do you get instead?

Not loaded.

How to fix:

Set public $dataFile = __DIR__ . '/data/init_login.php'; inside UserFixture

Additional info

Q A
Yii vesion 2.0.8
PHP version 7.0.4
Operating system Ubuntu 16.04
@sdlins
Copy link
Contributor Author

sdlins commented Jun 12, 2016

The ActiveFixture::getData() tries to guess the file name using sub folder data followed by the table name (user, in this case), i.e data/user.php that does not exists in app-advanced.

@AlekseyBykov
Copy link

Thank you for your posting! Works perfectly with MySQL, but don't work with MS SQL Server..

@samdark
Copy link
Member

samdark commented Jun 13, 2016

@AlekseyBykov how exactly it doesn't work?

@AlekseyBykov
Copy link

Hi, samdark! Thank you for your reply! I installed advanced application template, created two databases yii2advanced: one in the local MySQL another in the remote MS SQL Server. Applied the migration on both the databases. Next, I loaded fixture into the MySQL table tbl_user, the data is loaded successfully. Then tried to load fixture into the MS SQL Server's table [dbo].[tbl_user] but get exception:

Exception 'yii\base\InvalidParamException' with message 'Table not found: []'

Tried to define the table name as described below, several variants, all the have not helped:

public static function tableName()
{
    return 'dbo..tbl_user'
}
...
public static function tableName()
{
    return 'dbo.sa.tbl_user'
}
...
public static function tableName()
{
    return '{{dbo.sa.%user}}'
}
...

@AlekseyBykov
Copy link

AlekseyBykov commented Jun 13, 2016

I execute yii fixture/load User with the following configuration:

'components' => [
    'db' => [
        'class' => '\yii\db\Connection',
        'dsn' => 'sqlsrv:Server=...;Database=yii2advanced',
        'username' => 'sa',
        'password' => '...',
        'charset' => 'utf8',
        'tablePrefix' => 'tbl_',
    ],
],

Full stacktrace and command output:

C:\php-projects\advanced\tests\codeception\bin>yii fixture/load User
Fixtures namespace is:
        tests\codeception\common\fixtures

Global fixtures will be used:

        1. yii\test\InitDb

Fixtures below will be loaded:

        1. User

Be aware that:
Applying leads to purging of certain data in the database!

Load above fixtures? (yes|no) [no]:yes

Exception 'yii\base\InvalidParamException' with message 'Table not found: []'

in C:\php-projects\advanced\vendor\yiisoft\yii2\db\mssql\QueryBuilder.php:182

Stack trace:
0 C:\php-projects\advanced\vendor\yiisoft\yii2\db\Command.php(754): yii\db\mssql\QueryBuilder->checkIntegrity(false, '', '')
1 C:\php-projects\advanced\vendor\yiisoft\yii2\test\InitDbFixture.php(94): yii\db\Command->checkIntegrity(false, '')
2 C:\php-projects\advanced\vendor\yiisoft\yii2\test\InitDbFixture.php(76): yii\test\InitDbFixture->checkIntegrity(false)
3 C:\php-projects\advanced\vendor\yiisoft\yii2\test\FixtureTrait.php(114): yii\test\InitDbFixture->beforeUnload()
4 C:\php-projects\advanced\vendor\yiisoft\yii2\console\controllers\FixtureController.php(159): yii\console\controllers\FixtureController->unloadFixtures(Array)

5 [internal function]: yii\console\controllers\FixtureController->actionLoad('User')
6 C:\php-projects\advanced\vendor\yiisoft\yii2\base\InlineAction.php(55): call_user_func_array(Array, Array)
7 C:\php-projects\advanced\vendor\yiisoft\yii2\base\Controller.php(154): yii\base\InlineAction->runWithParams(Array)
8 C:\php-projects\advanced\vendor\yiisoft\yii2\console\Controller.php(119): yii\base\Controller->runAction('load', Array)
9 C:\php-projects\advanced\vendor\yiisoft\yii2\base\Module.php(454): yii\console\Controller->runAction('load', Array)
10 C:\php-projects\advanced\vendor\yiisoft\yii2\console\Application.php(176): yii\base\Module->runAction('fixture/load', Array)
11 C:\php-projects\advanced\vendor\yiisoft\yii2\console\Application.php(143): yii\console\Application->runAction('fixture/load', Array)
12 C:\php-projects\advanced\vendor\yiisoft\yii2\base\Application.php(375): yii\console\Application->handleRequest(Object(yii\console\Request))
13 C:\php-projects\advanced\tests\codeception\bin\yii(23): yii\base\Application->run()
14 {main}

Additional info

Q A
Yii vesion 2.0.7-dev or 2.0.8
PHP version 5.4.45
Operating system Windows 7 Home Basic or Windows 10 Pro

@samdark
Copy link
Member

samdark commented Aug 4, 2016

Testing bolilerplate was refactored. Is it still an issue?

@SilverFire
Copy link
Member

I'm closing the issue unless further information provided.

@boboldehampsink
Copy link

This is still an issue

@boboldehampsink
Copy link

I've created a fix for this: yiisoft/yii2#13572

@cebe cebe reopened this Feb 15, 2017
@cebe cebe added this to the 2.0.12 milestone Feb 15, 2017
@cebe cebe modified the milestones: 2.0.13, 2.0.12 Jun 5, 2017
@SilverFire
Copy link
Member

The PR yiisoft/yii2#13572 is merged. Is the issue resolved?

@samdark samdark closed this as completed Aug 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants