Repository: gobuffalo/pop (go)

Issue:
Reconnect DB after closing.
## Description

If this is a feature request, explain why it should be added. Specific use-cases are best.

For bug reports, please provide as much *relevant* info as possible.
 
When `Connection`  closed, it unable to open again.

### Steps to Reproduce the Problem

  Please describe in painful detail what you did (so others can play along with you) to get to this point. This includes things like the exact command(s) you used, or the `curl` command you used, that sort of thing.

```go
	users := []User{}
	for i := 0; i < 2; i++ {
		conn, err := pop.Connect("development")
		if err != nil {
			fmt.Println(err)
		}
		err = conn.All(&users)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		for _, u := range users {
			fmt.Println(u)
		}
		err = conn.Close()
		// conn.Store = nil // make Store to nil will continue the loop
		if err != nil {
			fmt.Println(err)
		}
	}
```
### Expected Behavior

connection will recconnect after closing

### Actual Behavior

```
unable to fetch records: sql: database is closed
```

### Info

Should set `Store = nil`  in Connection's Close method.


Pull request:
fix Connection.Close() to reset the store
As reported in #510, the `Connection.Close()` just closes the connection to the database but did not update the status of `Connection` so it could not be reused with `Open()`. 

This PR makes the method to reset `Store` so `Open()` can understand the status of the `Connection`. Also, added a test case for this issue.

fixes #510

Patch:
diff --git a/connection.go b/connection.go
index f51fd36..1fe2253 100644
--- a/connection.go
+++ b/connection.go
@@ -145,6 +145,7 @@ func (c *Connection) Close() error {
 	if err := c.Store.Close(); err != nil {
 		return fmt.Errorf("couldn't close connection: %w", err)
 	}
+	c.Store = nil
 	return nil
 }
 


Test patch:
diff --git a/connection_test.go b/connection_test.go
index 55c801e..90d5614 100644
--- a/connection_test.go
+++ b/connection_test.go
@@ -28,6 +28,21 @@ func Test_Connection_SimpleFlow(t *testing.T) {
 	r.NoError(err)
 }
 
+func Test_Connection_Open_Close_Reopen(t *testing.T) {
+	r := require.New(t)
+
+	c, err := NewConnection(&ConnectionDetails{
+		URL: "sqlite://file::memory:?_fk=true",
+	})
+	r.NoError(err)
+
+	for i := 0; i < 2; i++ {
+		r.NoError(c.Open())
+		r.NoError(c.Transaction(func(c *Connection) error { return nil }))
+		r.NoError(c.Close())
+	}
+}
+
 func Test_Connection_Open_NoDialect(t *testing.T) {
 	r := require.New(t)