upper / db

Data Access Layer (DAL) for PostgreSQL, CockroachDB, MySQL, SQLite and MongoDB with ORM-like features.
https://upper.io/
MIT License
3.53k stars 234 forks source link

Fix sqlite.New panic #635

Closed sdvcrx closed 3 years ago

sdvcrx commented 3 years ago

Hi!

When using sqlite.New(sqldb) to create db session, sess.ConnectionURL() is nil. Therefore a nil-pointer panic throwed.

I'm using PRAGMA database_list to get database name, here is the document about it .

Fix #633

xiam commented 3 years ago

Hello @sdvcrx,

Thanks, this looks useful, do you think you could also add a test case to demonstrate it? In order to add a specific test for sqlite you could create a sqlite_test.go file and add a AdapterTests struct that embeds testsuite.Suite, something similar to this: https://github.com/upper/db/blob/master/adapter/postgresql/postgresql_test.go#L138, then add a TestAdapter function to be able to run the new test suite: https://github.com/upper/db/blob/master/adapter/postgresql/postgresql_test.go#L1413

Thank you

sdvcrx commented 3 years ago

@xiam Please take a look again ;)

xiam commented 3 years ago

Thank you very much @sdvcrx !