Skip to content
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

Reconnect DB after closing. #510

Closed
Tracked by #770
ofofofofo opened this issue Jan 10, 2020 · 1 comment · Fixed by #781
Closed
Tracked by #770

Reconnect DB after closing. #510

ofofofofo opened this issue Jan 10, 2020 · 1 comment · Fixed by #781
Assignees
Labels
bug Something isn't working s: fixed was fixed or solution offered
Milestone

Comments

@ofofofofo
Copy link

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.

	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.

@ofofofofo ofofofofo changed the title Recconect DB after closing. Reconnect DB after closing. Jan 10, 2020
@sio4 sio4 added the s: triage Some tests need to be run to confirm the issue label Sep 20, 2022
@sio4 sio4 added this to the v6.0.7 milestone Sep 20, 2022
@sio4 sio4 mentioned this issue Sep 20, 2022
30 tasks
@sio4 sio4 self-assigned this Sep 24, 2022
@sio4 sio4 added s: accepted This proposal was accepted. Someone can start working on it. and removed s: triage Some tests need to be run to confirm the issue labels Sep 24, 2022
@sio4
Copy link
Member

sio4 commented Sep 24, 2022

Indeed, it could be an issue in a complex application that need to control the connection state. will fix.

@sio4 sio4 closed this as completed in #781 Sep 24, 2022
@sio4 sio4 added bug Something isn't working s: fixed was fixed or solution offered and removed s: accepted This proposal was accepted. Someone can start working on it. labels Sep 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working s: fixed was fixed or solution offered
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants