-
Notifications
You must be signed in to change notification settings - Fork 443
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
Add support for SQLite :memory: databases. #551
base: master
Are you sure you want to change the base?
Add support for SQLite :memory: databases. #551
Conversation
$cached_connection was needed so that new, empty db wasn’t created on every call.
} | ||
catch (ActiveRecord\DatabaseException $e) | ||
{ | ||
$this->assertFalse(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be using $this->fail('optional message');
Think this looks fine, apart from the comment before. Although have not tested it yet. |
Fixed the assertion. Thanks! |
@@ -177,6 +178,9 @@ public static function parse_connection_url($connection_url) | |||
{ | |||
$url = @parse_url($connection_url); | |||
|
|||
if ( $url['scheme'] == "sqlite" && $url['host'] == ":memory" ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind dropping whitespace between parens?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
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 mytesting
environment, 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.