-
-
Notifications
You must be signed in to change notification settings - Fork 31
Update NewPool logic in regards to poolsize > 1 with inmemory set #125
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
base: main
Are you sure you want to change the base?
Conversation
Update what pool params are accepted
Forgot strings package
Makes the logic easier to read
if poolSize != 1 { | ||
uriLower := strings.ToLower(uri) | ||
inMemory := uri == ":memory:" || opts.Flags&sqlite.OpenMemory != 0 | ||
sharedCache := strings.Contains(uriLower, "cache=shared") || opts.Flags&sqlite.OpenSharedCache != 0 |
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.
Although unlikely, the cache=shared
string could appear in the file name. I think we need to do some minimal parsing of the URI (and ensure that the URI is, in fact, being parsed as a URI). Off-hand, you might be able to get away with splitting on the ?
and doing url.ParseQuery
, but double-check the docs to make sure there isn't some subtlety that I haven't thought of.
case err != nil && !test.wantErr: | ||
t.Errorf("TestInvalidPoolOptions(%s): got err == %s, want err == nil", test.name, err) | ||
continue | ||
} |
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.
For error tests like these, I like including a case that logs the error message in successful cases without failing. This allows manual inspection to see whether there's a case that's failing for an unrelated error cause.
for _, test := range tests { | ||
dbpool, err := sqlitex.NewPool(test.uri, sqlitex.PoolOptions{ | ||
Flags: test.flags, | ||
PoolSize: 2, |
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.
We should vary the pool size for some of these tests.
dbFileShared := filepath.Join(dir, "awal.db?cache=shared") | ||
|
||
tests := []struct { | ||
name string |
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.
Names aren't being used and aren't helpful here. Remove, please.
|
||
if poolSize != 1 { | ||
uriLower := strings.ToLower(uri) | ||
inMemory := uri == ":memory:" || opts.Flags&sqlite.OpenMemory != 0 |
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.
mode=memory
is another way this condition can be triggered.
For whatever reason I don't seem to get emails for comments any longer (I should fix that). I'll have a look at these in the next few days as time allows and make the changes. |
This addressed Issue: #124