diff --git a/db.go b/db.go index 961b37f9e0df18a5bdb839bbece9277a5d4b7d66..bc39292887a0d8ffb0deb8e094525d285f58a6bc 100644 --- a/db.go +++ b/db.go @@ -203,13 +203,6 @@ type Database interface { // Collections returns the names of all non-system tables on the database. Collections() ([]string, error) - // Use attempts to connect to another database using the same connection - // settings. - Use(string) error - - // Drop deletes all tables on the active database and drops the database. - Drop() error - // Setup stores database connection settings. Setup(ConnectionURL) error diff --git a/mongo/database.go b/mongo/database.go index 44d61e4b3715ada6a6a32b03dcfc6f7f4ad7dd6a..675cd1c165f37b2ba17775345a9b8017ab4db681 100644 --- a/mongo/database.go +++ b/mongo/database.go @@ -115,27 +115,6 @@ func (s *Source) Close() error { return nil } -// Use changes the active database. -func (s *Source) Use(database string) (err error) { - var conn ConnectionURL - - if conn, err = ParseURL(s.connURL.String()); err != nil { - return err - } - - conn.Database = database - - s.connURL = conn - - return s.Open() -} - -// Drop drops the current database. -func (s *Source) Drop() error { - err := s.database.DropDatabase() - return err -} - // Collections returns a list of non-system tables from the database. func (s *Source) Collections() (cols []string, err error) { var rawcols []string diff --git a/mongo/database_test.go b/mongo/database_test.go index 93e297dbb11e55e37d742c5bb7a55145a1625a50..7052b39d264c496577d9b0024229e785d1355bdf 100644 --- a/mongo/database_test.go +++ b/mongo/database_test.go @@ -195,25 +195,6 @@ func TestOpenWithWrongData(t *testing.T) { } } -// Test USE -func TestUse(t *testing.T) { - var err error - var sess db.Database - - // Opening database, no error expected. - if sess, err = db.Open(Adapter, settings); err != nil { - t.Fatal(err) - } - - // Connecting to another database, error expected. - if err = sess.Use("."); err == nil { - t.Fatal("This is not a database") - } - - // Closing connection. - sess.Close() -} - // Truncates all collections. func TestTruncate(t *testing.T) { diff --git a/mysql/database.go b/mysql/database.go index 95485b0955678947e699904b02dbd0d777727f9d..7f08baf7353b92f5484e4757712e79a0942d8742 100644 --- a/mysql/database.go +++ b/mysql/database.go @@ -80,19 +80,6 @@ func (d *database) Setup(connURL db.ConnectionURL) error { return d.Open() } -// Use changes the active database. -func (d *database) Use(name string) (err error) { - var conn ConnectionURL - if conn, err = ParseURL(d.ConnectionURL().String()); err != nil { - return err - } - conn.Database = name - if d.BaseDatabase != nil { - d.Close() - } - return d.Setup(conn) -} - // Clone creates a new database connection with the same settings as the // original. func (d *database) Clone() (db.Database, error) { @@ -125,18 +112,6 @@ func (d *database) Collections() (collections []string, err error) { return collections, nil } -// Drop removes all tables from the current database. -func (d *database) Drop() error { - stmt := &sqlgen.Statement{ - Type: sqlgen.DropDatabase, - Database: sqlgen.DatabaseWithName(d.Schema().Name()), - } - if _, err := d.Builder().Exec(stmt); err != nil { - return err - } - return nil -} - // Transaction starts a transaction block and returns a db.Tx struct that can // be used to issue transactional queries. func (d *database) Transaction() (db.Tx, error) { diff --git a/postgresql/database.go b/postgresql/database.go index 700daac61b2a2934d147e51724f1bcbf1796ae5b..ffb30cb33d4e4141c31cf664fb4c515dd00eeb58 100644 --- a/postgresql/database.go +++ b/postgresql/database.go @@ -93,19 +93,6 @@ func (d *database) Setup(connURL db.ConnectionURL) error { return d.Open() } -// Use changes the active database. -func (d *database) Use(name string) (err error) { - var conn ConnectionURL - if conn, err = ParseURL(d.ConnectionURL().String()); err != nil { - return err - } - conn.Database = name - if d.BaseDatabase != nil { - d.Close() - } - return d.Setup(conn) -} - // Clone creates a new database connection with the same settings as the // original. func (d *database) Clone() (db.Database, error) { @@ -137,18 +124,6 @@ func (d *database) Collections() (collections []string, err error) { return collections, nil } -// Drop removes all tables from the current database. -func (d *database) Drop() error { - stmt := &sqlgen.Statement{ - Type: sqlgen.DropDatabase, - Database: sqlgen.DatabaseWithName(d.Schema().Name()), - } - if _, err := d.Builder().Exec(stmt); err != nil { - return err - } - return nil -} - // Transaction starts a transaction block and returns a db.Tx struct that can // be used to issue transactional queries. func (d *database) Transaction() (db.Tx, error) { diff --git a/ql/database.go b/ql/database.go index 91b7946a1fea7c6e0bbd46c5f8f3fceab4a84705..3612c7198a71db4460ee110d59f845c2b3e1ce55 100644 --- a/ql/database.go +++ b/ql/database.go @@ -120,19 +120,6 @@ func (d *database) Setup(connURL db.ConnectionURL) error { return d.Open() } -// Use changes the active database. -func (d *database) Use(name string) (err error) { - var conn ConnectionURL - if conn, err = ParseURL(d.ConnectionURL().String()); err != nil { - return err - } - conn.Database = name - if d.BaseDatabase != nil { - d.Close() - } - return d.Setup(conn) -} - func (d *database) Close() error { if d.BaseDatabase != nil { if atomic.AddInt32(&fileOpenCount, -1) < 0 { @@ -177,18 +164,6 @@ func (d *database) Collections() (collections []string, err error) { return collections, nil } -// Drop removes all tables from the current database. -func (d *database) Drop() error { - stmt := &sqlgen.Statement{ - Type: sqlgen.DropDatabase, - Database: sqlgen.DatabaseWithName(d.Schema().Name()), - } - if _, err := d.Builder().Exec(stmt); err != nil { - return err - } - return nil -} - // Transaction starts a transaction block and returns a db.Tx struct that can // be used to issue transactional queries. func (d *database) Transaction() (db.Tx, error) { diff --git a/sqlite/database.go b/sqlite/database.go index 5752917f7472d3988e63836277b01dc9f99cc152..59b33319427d56617a5da28de0b374d915272b01 100644 --- a/sqlite/database.go +++ b/sqlite/database.go @@ -110,19 +110,6 @@ func (d *database) Setup(connURL db.ConnectionURL) error { return d.Open() } -// Use changes the active database. -func (d *database) Use(name string) (err error) { - var conn ConnectionURL - if conn, err = ParseURL(d.ConnectionURL().String()); err != nil { - return err - } - conn.Database = name - if d.BaseDatabase != nil { - d.Close() - } - return d.Setup(conn) -} - func (d *database) Close() error { if d.Session() != nil { if atomic.AddInt32(&fileOpenCount, -1) < 0 { @@ -164,18 +151,6 @@ func (d *database) Collections() (collections []string, err error) { return collections, nil } -// Drop removes all tables from the current database. -func (d *database) Drop() error { - stmt := &sqlgen.Statement{ - Type: sqlgen.DropDatabase, - Database: sqlgen.DatabaseWithName(d.Schema().Name()), - } - if _, err := d.Builder().Exec(stmt); err != nil { - return err - } - return nil -} - // Transaction starts a transaction block and returns a db.Tx struct that can // be used to issue transactional queries. func (d *database) Transaction() (db.Tx, error) {