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

[SQLite Platform] doctrine:database:create --if-not-exists fix #2402

Closed
wants to merge 4 commits into from
Closed

[SQLite Platform] doctrine:database:create --if-not-exists fix #2402

wants to merge 4 commits into from

Conversation

eugene-matvejev
Copy link

@eugene-matvejev eugene-matvejev commented May 22, 2016

problem description: doctrine/DoctrineBundle#542

@@ -180,6 +180,14 @@ protected function _getTransactionIsolationLevelSQL($level)
/**
* {@inheritDoc}
*/
public function getListDatabasesSQL()
{
return 'PRAGMA databases';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In sqlite the PRAGMA is "database_list" not "databases".
You will need to fix the tests and verify that the ouput of that PRAGMA is comparable to the output of the others platforms.

@eugene-matvejev
Copy link
Author

eugene-matvejev commented Jun 4, 2016

I tried fix it, basically PRAGMA database_list return array [see below] while database file been created in root directory (or in directory from tests been launched)

whenever I launch it with command:
./vendor/bin/phpunit --configuration tests/travis/sqlite.travis.xml

test_create_database file been created in root, but

    public function testListDatabases()
    {
        if (!$this->_sm->getDatabasePlatform()->supportsCreateDropDatabase()) {
            $this->markTestSkipped('Cannot drop Database client side with this Driver.');
        }

        $this->_sm->dropAndCreateDatabase('test_create_database');
        $databases = $this->_sm->listDatabases();
        /** left for debug purposes */
        $databases_ = [];
        foreach ($databases as $database) {
            $databases_[] = is_array($database) ? strtolower($database['name']) : $database;
        }

        $this->assertContains('test_create_database', $databases_);
    }

$databases content:

Array
(
    [0] => Array
        (
            [seq] => 0
            [name] => main
            [file] => 
        )
    [1] => Array
        (
            [seq] => 1
            [name] => temp
            [file] => 
        )
)

i presume it should detect test_create_database file , what I am doing wrong? I didn't catch =/

@eugene-matvejev
Copy link
Author

bump!

@eugene-matvejev
Copy link
Author

@mikeSimonson seems you have more experience with SQLIte than me, can you please help?

eugene-matvejev added a commit to eugene-matvejev/symfony-battleship that referenced this pull request Jul 24, 2016
@mikeSimonson mikeSimonson self-assigned this Jul 25, 2016
@deeky666 deeky666 removed this from the 2.6 milestone May 10, 2017
@sharif9876
Copy link

Any updates on this? It's still an issue

{
$this->_sm->listDatabases();
}
// /**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's dead, it should be removed

@@ -127,10 +127,13 @@ public function testListDatabases()

$this->_sm->dropAndCreateDatabase('test_create_database');
$databases = $this->_sm->listDatabases();
/** left for debug purposes */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove - debugging stuff only while debugging please

$databases = array_map('strtolower', $databases);

$this->assertContains('test_create_database', $databases);
$this->assertContains('test_create_database', $databases_);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return format of SchemaManager#listDatabases() changed: that is a BC break.


$databases = array_map('strtolower', $databases);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please DO ADD a test to demonstrate your issue, rather than modifying existing tests.

@ostrolucky
Copy link
Member

Closing, as author never got around to finish this. If you ever intend to finish this, feel free to open new PR. Thanks!

@ostrolucky ostrolucky closed this May 30, 2019
@kevinpapst kevinpapst mentioned this pull request Nov 26, 2019
3 tasks
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants