Add support for SQLite :memory: databases.#551
Open
claytonrcarter wants to merge 3 commits intojpfuentes2:masterfrom
Open
Add support for SQLite :memory: databases.#551claytonrcarter wants to merge 3 commits intojpfuentes2:masterfrom
claytonrcarter wants to merge 3 commits intojpfuentes2:masterfrom
Conversation
$cached_connection was needed so that new, empty db wasn’t created on every call.
| } | ||
| catch (ActiveRecord\DatabaseException $e) | ||
| { | ||
| $this->assertFalse(true); |
Collaborator
There was a problem hiding this comment.
You should be using $this->fail('optional message');
Collaborator
|
Think this looks fine, apart from the comment before. Although have not tested it yet. |
Author
|
Fixed the assertion. Thanks! |
| { | ||
| $url = @parse_url($connection_url); | ||
|
|
||
| if ( $url['scheme'] == "sqlite" && $url['host'] == ":memory" ) |
Owner
There was a problem hiding this comment.
Mind dropping whitespace between parens?
Author
There was a problem hiding this comment.
Sure thing. I think I found and fixed them all. Thanks!
|
Is this expected to be merged? I'd like to use a memory adapter but I can't on the current release. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These were some fairly simple changes that don't really add support for SQLite
:memory:databases, so much as they unlock support for them.Use Case:
Unit testing code that uses PHP-AR without relying on a live db connection. I can use
sqlite://:memory:for mytestingenvironment, run migrations in my testset_up(), then run tests. Super fast. ⚡Notes:
:memory:databases by just running all SQLite tests again withsqlite://:memory:as DSN instead ofsqlite://test.db. It would be good for someone to confirm that this is really testing what it should be testing.