-
-
Notifications
You must be signed in to change notification settings - Fork 246
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
Proposal: clean up connection_details.go #281
Comments
Looks good to me. I'll check your PR by the end of the week. :) |
How about adding test like this? func Test_MySQL_DB_Operations(t *testing.T) {
r := require.New(t)
err := LoadConfigFile()
r.NoError(err)
testFor := os.Getenv("SODA_DIALECT")
if "mysql" != testFor {
return // not my turn
}
if "on" != os.Getenv("POP_EXTRA_TEST") {
t.Log("Skip extra DDL tests for mysql.")
t.Log("POP_EXTRA_TEST=on if you want to run extra tests.")
return
}
t.Logf("Current SODA_DIALECT is %v. Test more...\n", testFor)
connection := Connections[testFor]
r.NotNil(connection, "oops! doing extra tests but could not found connection!")
t.Logf("Use connection: %v\n", Connections[testFor])
testDB := "pop_test_mysql_extra"
cd := connection.Dialect.Details()
cd.Database = testDB
d := connection.Dialect
d.DropDB()
err = d.CreateDB()
r.NoError(err)
err = d.CreateDB()
r.Error(err)
err = d.DropDB()
r.NoError(err)
} Although before testing, we do By the way, is there any reason for did not connect to any test coverage management tools? |
Great work with this lib everyone! Love the idea of cleanup. "Since there are some kind of differences on each dialect" bit got me, when I tried to deploy to Google Cloud SQL (PostgreSQL). PostgreSQL accepts connection string that does not contain the URL format expected by Pop. App Engine Flex and the new App Engine Standard are both expecting that format when trying to connect to Cloud SQL instance (due to the Unix domain socket). Example: Related issue: #53 Currently, Pop is trying to parse the URL: Line 57 in 2826150
which makes the use of connection string format impossible. As a quick workaround, I managed to get around that by adding the condition: Hopefully, the cleanup would be able to address that issue more nicely. |
Hi @B-Scan, Basically, I consider about adding additional database engines probably added in the future and some variations of existing database engines as you mentioned GCP edition of Postgres, and more. I think the first goal for this is that if we need to add an additional database engine, it should be adding a single file, not modifying others like And I also think we need to consider variations. It can be different versions of the same engine, or differently implemented services using the same database engine. To solve this issue, I added Although this part is not the main body of the library, it can help to make the base more stable. |
This should be done now, thanks! :) |
Hello, While I am looking in the file
connection_details.go
several times, I think it was originally born to be store common connection information structure and related functions like parsing URL. But since there are some kind of differences on each dialect, now it mixed with someswitch
s and if buffalo and pop grow more, it will become more complex.So in my opinion, all things depend on specific database engines should be moved to its dialect file and
connection_details.go
should stay with common things. (of course, I also guess dialect_*.go was born to support differences of something like SQL syntaxes basically, I think we can just treat it as drivers.)@markbates, and other maintainers,
If you agree with my idea, I will start to clean up the codes. Today's idea is, just simply,
Ideas
Port
and MySQL specific URL parser.ConnectionDetails
structure and configurations to useOptions
more.Encoding
is used my MySQL only. It can be moved underOptions
and,connection_details.go
(something like I PRed for cockroach)multiStatement
for MySQL, shoud handled by function that handle default values for each dialect, with standard form.Encoding
)I think above changes are good starting point of the change.
How do you think about this?
The text was updated successfully, but these errors were encountered: