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

Connections obtained with Database#using_connection should not be auto released #35

Closed
ggiraldez opened this issue Jan 11, 2017 · 0 comments · Fixed by #36
Closed

Connections obtained with Database#using_connection should not be auto released #35

ggiraldez opened this issue Jan 11, 2017 · 0 comments · Fixed by #36
Labels

Comments

@ggiraldez
Copy link
Collaborator

ggiraldez commented Jan 11, 2017

This code:

require "db"
require "pg"

DB.open("postgres://localhost/foo") do |db|
  db.using_connection do |conn|
    conn.exec("select now();")
    conn.exec("select now();")
    conn.exec("select now();")
  end
end

fails with a closed stream (IO::Error) exception on the third call to exec. From a quick code inspection, #exec always returns the connection to the pool, regardless of how it was obtained, but I'd expect the connection to be held in a checkout state when used inside the using_connection block.

crystal-db version: 0.3.3
crystal-pg version: 0.13.1

@ggiraldez ggiraldez added the bug label Jan 11, 2017
bcardiff pushed a commit that referenced this issue Jan 12, 2017
add auto_release to DB::Connection (default true on each pool checkout).
fixes #35.
bcardiff pushed a commit that referenced this issue Jan 16, 2017
add auto_release to DB::Connection (default true on each pool checkout).
fixes #35.
bcardiff added a commit that referenced this issue Jan 16, 2017
add auto_release to DB::Connection (default true on each pool checkout).
fixes #35.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant