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

DBAL-332: Memory option for Sqlite driver does nothing #1518

Closed
doctrinebot opened this issue Aug 29, 2012 · 9 comments
Closed

DBAL-332: Memory option for Sqlite driver does nothing #1518

doctrinebot opened this issue Aug 29, 2012 · 9 comments
Assignees
Labels

Comments

@doctrinebot
Copy link

Jira issue originally created by user dalexandre:

I'm trying to configure a "memory" sqlite database, as described here: http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#pdo-sqlite

So here is my configuration (config_test.yml) :

doctrine:
    dbal:
        driver:    pdo_sqlite
        memory:    true
        user:      db_user
        password:  db_pwd
        charset:   UTF8

I'm then running ./app/console doctrine:database:create --env=test and the result is a "myBdName" db file (the filename contains the quote!!) in my root folder.

I don't understand why the file http://www.doctrine-project.org/api/dbal/2.3/source-class-Doctrine.DBAL.Schema.SqliteSchemaManager.html#46 is creating a path option with my DB name, if I comment the line 57, everything seems fine (no more file created).

I have seen some memory related options in the Doctrine test suite so maybe I'm doing it wrong, and in that case that's a documentation issue I can work on.

Thx,
Damien

@doctrinebot
Copy link
Author

Comment created by @beberlei:

You cannot create an in memory database using Symfonys database:create. The in memory database will be closed when the request ends. So its completly useless this way. You have to recreate it in every request that you want to use it. It is just good for one request.

@doctrinebot
Copy link
Author

Comment created by dalexandre:

My example with "app/console" is misleading,
what I want to do is building a memory SQLite database on the fly and run some code right after it (in a phpunit test).

The issue here is that there is an option documented (first link) that doesn't work / is not implemented (second link). And a physic file is generated, it should not.

As your answer seems to be based on the mistaken impression that I wanted to use volatile database in a persistent way, I'm reopening this issue.

Thanks for your time.
Damien.

@doctrinebot
Copy link
Author

Comment created by @beberlei:

Try removing the user/password keys. memory database connection works for me, this seems to be a configuration issue.

If you want to create an in memory db for testing then you have to create the schema with SchemaTool inside the phpunit tests.

@doctrinebot
Copy link
Author

Comment created by @beberlei:

No feedback on potential fix, this issue is either misconfiguration or wrong use of the API. I couldn't reproduce this and it works for me (TM).

@doctrinebot
Copy link
Author

Issue was closed with resolution "Invalid"

@doctrinebot
Copy link
Author

Comment created by iainp999:

Hi guys, this does not work for me either. Same use case.

Config:

driver: pdo_sqlite
memory: true

@doctrinebot
Copy link
Author

Comment created by iainp999:

Apologies for resurrecting an old issue but a google search brought me here.

@0xMatt
Copy link

0xMatt commented Jan 23, 2016

Issue still persists with latest doctrine/orm and doctrine-bundle packages. Just to recap on what's happening, a file "projectname" with quotes is being created in the project root, and we are getting an sql error saying the table we are querying is not found.

here's the gist of my implementation in case it's an issue on my end - https://gist.github.com/0xMatt/19b9432a86c5737a5cd9

In case it might be mentioned, I have also tried setting the path to :memory:

@github-actions
Copy link

github-actions bot commented Aug 7, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants