<?xml version="1.0" encoding="UTF-8"?>
<ticket>
  <assigned-user-id type="integer">141</assigned-user-id>
  <attachments-count type="integer">7</attachments-count>
  <closed type="boolean">true</closed>
  <created-at type="datetime">2009-01-13T22:36:38+00:00</created-at>
  <creator-id type="integer">37814</creator-id>
  <milestone-due-on type="datetime" nil="true"></milestone-due-on>
  <milestone-id type="integer">9903</milestone-id>
  <number type="integer">1752</number>
  <permalink>added-using_connection-method-like-with_connection-but-sets-it-as-default-connection-while-inside-the-block</permalink>
  <priority type="integer">1058</priority>
  <project-id type="integer">8994</project-id>
  <raw-data type="binary" nil="true" encoding="base64"></raw-data>
  <state>resolved</state>
  <tag>activerecord connection patch pool</tag>
  <title>Modifying with_connection method</title>
  <updated-at type="datetime">2009-05-01T14:58:51+01:00</updated-at>
  <user-id type="integer">17393</user-id>
  <user-name>Repository</user-name>
  <creator-name>coderrr</creator-name>
  <assigned-user-name>Michael Koziarski</assigned-user-name>
  <url>http://rails.lighthouseapp.com/projects/8994/tickets/1752</url>
  <milestone-title>2.x</milestone-title>
  <original-body>More useful version of with_connection.  If you wrap all your code which makes AR queries with this method you don't have to worry about connection cleanup.</original-body>
  <latest-body>More useful version of with_connection.  If you wrap all your code which makes AR queries with this method you don't have to worry about connection cleanup.</latest-body>
  <original-body-html>&lt;div&gt;&lt;p&gt;More useful version of with_connection. If you wrap all your
code which makes AR queries with this method you don't have to
worry about connection cleanup.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  <versions type="array">
    <version type="Ticket::Version">
      <assigned-user-id type="integer" nil="true"></assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>More useful version of with_connection.  If you wrap all your code which makes AR queries with this method you don't have to worry about connection cleanup.  It simply release the connection when the block is done.  It also protects against releasing the connection inside of nested calls, it will only release when the topmost call completes (see test for example of this)

The following code will leave 1 connection checked out of the connection pool

    Thread.new do
      ActiveRecord::Base.connection_pool.with_connection do |this_conn_isnt_actually_used|
        User.all
      end
    end.join

But with cleanup_connection the connection will be checked in after the block completes.  The connection pool will be in its original state when this code finishes.

    Thread.new do
      ActiveRecord::Base.connection_pool.cleanup_connection do
        User.all
      end
    end.join</body>
      <body-html>&lt;div&gt;&lt;p&gt;More useful version of with_connection. If you wrap all your
code which makes AR queries with this method you don't have to
worry about connection cleanup. It simply release the connection
when the block is done. It also protects against releasing the
connection inside of nested calls, it will only release when the
topmost call completes (see test for example of this)&lt;/p&gt;
&lt;p&gt;The following code will leave 1 connection checked out of the
connection pool&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;Thread.new do
  ActiveRecord::Base.connection_pool.with_connection do |this_conn_isnt_actually_used|
    User.all
  end
end.join
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;But with cleanup_connection the connection will be checked in
after the block completes. The connection pool will be in its
original state when this code finishes.&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;Thread.new do
  ActiveRecord::Base.connection_pool.cleanup_connection do
    User.all
  end
end.join
&lt;/code&gt;
&lt;/pre&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-01-13T22:36:38+00:00</created-at>
      <creator-id type="integer">37814</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1752</number>
      <permalink>added-using_connection-method-like-with_connection-but-sets-it-as-default-connection-while-inside-the-block</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>patch</tag>
      <title>added using_connection method; like with_connection but sets it as default connection while inside the block </title>
      <updated-at type="datetime">2009-01-16T00:23:38+00:00</updated-at>
      <user-id type="integer">37814</user-id>
      <user-name>coderrr</user-name>
      <creator-name>coderrr</creator-name>
      <assigned-user-name nil="true"></assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1752</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body></body>
      <body-html></body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-01-13T23:03:02+00:00</created-at>
      <creator-id type="integer">37814</creator-id>
      <diffable-attributes type="yaml">--- 
:tag: patch
:assigned_user: 
:title: &quot;added using_connection method; like with_connection but sets it as default connection while inside the block &quot;
</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1752</number>
      <permalink>added-using_connection-method-like-with_connection-but-sets-it-as-default-connection-while-inside-the-block</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>activerecord connection patch pool</tag>
      <title>Adding using_connection method</title>
      <updated-at type="datetime">2009-01-13T23:03:03+00:00</updated-at>
      <user-id type="integer">1366</user-id>
      <user-name>Pratik</user-name>
      <creator-name>coderrr</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1752</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>example of why nesting protection is very helpful
@@@ ruby
def x
  using_connection do
    User.all.each {|u| y(u) }
  end
end

def y(u)
  using_connection do
    u.something = rand
    u.save!
  end
end

def z
  y(@user)
end
@@@

Basically it allows you to only wrap code which is immediately doing an AR update without having to worry about nesting issues.</body>
      <body-html>&lt;div&gt;&lt;p&gt;example of why nesting protection is very helpful&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;
def x
  using_connection do
    User.all.each {|u| y(u) }
  end
end

def y(u)
  using_connection do
    u.something = rand
    u.save!
  end
end

def z
  y(@user)
end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Basically it allows you to only wrap code which is immediately
doing an AR update without having to worry about nesting
issues.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-01-14T06:29:43+00:00</created-at>
      <creator-id type="integer">37814</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1752</number>
      <permalink>added-using_connection-method-like-with_connection-but-sets-it-as-default-connection-while-inside-the-block</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>activerecord connection patch pool</tag>
      <title>Adding using_connection method</title>
      <updated-at type="datetime">2009-01-14T06:29:46+00:00</updated-at>
      <user-id type="integer">37814</user-id>
      <user-name>coderrr</user-name>
      <creator-name>coderrr</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1752</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>Realized all I really care about is cleaning up the connection at the end of the block, so here's a simpler version.  It doesn't explicitly check out the connection.  That will be done by AR on the first call to AR::B.connection.

Test for nesting safety added.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Realized all I really care about is cleaning up the connection
at the end of the block, so here's a simpler version. It doesn't
explicitly check out the connection. That will be done by AR on the
first call to AR::B.connection.&lt;/p&gt;
&lt;p&gt;Test for nesting safety added.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-01-14T19:58:42+00:00</created-at>
      <creator-id type="integer">37814</creator-id>
      <diffable-attributes type="yaml">--- 
:title: Adding using_connection method
</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1752</number>
      <permalink>added-using_connection-method-like-with_connection-but-sets-it-as-default-connection-while-inside-the-block</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>activerecord connection patch pool</tag>
      <title>Adding cleanup_connection method</title>
      <updated-at type="datetime">2009-01-14T19:58:47+00:00</updated-at>
      <user-id type="integer">37814</user-id>
      <user-name>coderrr</user-name>
      <creator-name>coderrr</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1752</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">2</attachments-count>
      <body>added more real-world test case for nesting safety</body>
      <body-html>&lt;div&gt;&lt;p&gt;added more real-world test case for nesting safety&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-01-14T22:03:34+00:00</created-at>
      <creator-id type="integer">37814</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1752</number>
      <permalink>added-using_connection-method-like-with_connection-but-sets-it-as-default-connection-while-inside-the-block</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>activerecord connection patch pool</tag>
      <title>Adding cleanup_connection method</title>
      <updated-at type="datetime">2009-01-14T22:03:37+00:00</updated-at>
      <user-id type="integer">37814</user-id>
      <user-name>coderrr</user-name>
      <creator-name>coderrr</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1752</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">3</attachments-count>
      <body>renamed thread local variable to cleanup_connection</body>
      <body-html>&lt;div&gt;&lt;p&gt;renamed thread local variable to cleanup_connection&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-01-14T22:05:42+00:00</created-at>
      <creator-id type="integer">37814</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1752</number>
      <permalink>added-using_connection-method-like-with_connection-but-sets-it-as-default-connection-while-inside-the-block</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>activerecord connection patch pool</tag>
      <title>Adding cleanup_connection method</title>
      <updated-at type="datetime">2009-01-14T22:05:48+00:00</updated-at>
      <user-id type="integer">37814</user-id>
      <user-name>coderrr</user-name>
      <creator-name>coderrr</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1752</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">4</attachments-count>
      <body>+1</body>
      <body-html>&lt;div&gt;&lt;p&gt;+1&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-01-17T22:59:23+00:00</created-at>
      <creator-id type="integer">37814</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1752</number>
      <permalink>added-using_connection-method-like-with_connection-but-sets-it-as-default-connection-while-inside-the-block</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>activerecord connection patch pool</tag>
      <title>Adding cleanup_connection method</title>
      <updated-at type="datetime">2009-01-17T22:59:24+00:00</updated-at>
      <user-id type="integer">21029</user-id>
      <user-name>hosiawak</user-name>
      <creator-name>coderrr</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1752</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">4</attachments-count>
      <body>+1

This patch lets me use ActiveRecord in Ramaze.  A most timely patch.</body>
      <body-html>&lt;div&gt;&lt;p&gt;+1&lt;/p&gt;
&lt;p&gt;This patch lets me use ActiveRecord in Ramaze. A most timely
patch.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-04T05:35:53+00:00</created-at>
      <creator-id type="integer">37814</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1752</number>
      <permalink>added-using_connection-method-like-with_connection-but-sets-it-as-default-connection-while-inside-the-block</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>activerecord connection patch pool</tag>
      <title>Adding cleanup_connection method</title>
      <updated-at type="datetime">2009-02-04T05:35:57+00:00</updated-at>
      <user-id type="integer">46153</user-id>
      <user-name>Michael Lang</user-name>
      <creator-name>coderrr</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1752</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">4</attachments-count>
      <body>Moved cleanup_connection method to ConnectionHandler.  Using clear_active_connections! instead of release_connection so we release connections from all connection pools in use by the current thread.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Moved cleanup_connection method to ConnectionHandler. Using
clear_active_connections! instead of release_connection so we
release connections from all connection pools in use by the current
thread.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-17T21:31:53+00:00</created-at>
      <creator-id type="integer">37814</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1752</number>
      <permalink>added-using_connection-method-like-with_connection-but-sets-it-as-default-connection-while-inside-the-block</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>activerecord connection patch pool</tag>
      <title>Adding cleanup_connection method</title>
      <updated-at type="datetime">2009-02-17T21:31:57+00:00</updated-at>
      <user-id type="integer">37814</user-id>
      <user-name>coderrr</user-name>
      <creator-name>coderrr</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1752</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">5</attachments-count>
      <body>As requested by lifo

Real World Usecase:

You have 100 threads which stay alive and running throughout the entire life of your process.  These threads are intermittently doing AR calls.  Now assume you can't or don't want to increase your connection pool size to 100.  Or assume instead of 100 its some unknown number of threads which might be higher than you can set your connection pool size to.

Without this patch each thread will hold onto a single connection even though it's not making use of it most of the time.  With this patch you can wrap all your AR access in a cleanup_connection block and the thread will release the connection whenever its finished with it.  This will allow you to get away with a small connection pool even with lots of threads using AR.</body>
      <body-html>&lt;div&gt;&lt;p&gt;As requested by lifo&lt;/p&gt;
&lt;p&gt;Real World Usecase:&lt;/p&gt;
&lt;p&gt;You have 100 threads which stay alive and running throughout the
entire life of your process. These threads are intermittently doing
AR calls. Now assume you can't or don't want to increase your
connection pool size to 100. Or assume instead of 100 its some
unknown number of threads which might be higher than you can set
your connection pool size to.&lt;/p&gt;
&lt;p&gt;Without this patch each thread will hold onto a single
connection even though it's not making use of it most of the time.
With this patch you can wrap all your AR access in a
cleanup_connection block and the thread will release the connection
whenever its finished with it. This will allow you to get away with
a small connection pool even with lots of threads using AR.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-17T22:25:52+00:00</created-at>
      <creator-id type="integer">37814</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1752</number>
      <permalink>added-using_connection-method-like-with_connection-but-sets-it-as-default-connection-while-inside-the-block</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>activerecord connection patch pool</tag>
      <title>Adding cleanup_connection method</title>
      <updated-at type="datetime">2009-02-17T22:25:58+00:00</updated-at>
      <user-id type="integer">37814</user-id>
      <user-name>coderrr</user-name>
      <creator-name>coderrr</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1752</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">5</attachments-count>
      <body>I can appreciate the desire for this patch, but what about just piggy-backing off the existing connection method instead? Consider this patch: 

http://gist.github.com/66038

It's just a proof-of-concept, may need some cleaning up and adding tests/merging w/ coderrr's patch.

What do you think?</body>
      <body-html>&lt;div&gt;&lt;p&gt;I can appreciate the desire for this patch, but what about just
piggy-backing off the existing connection method instead? Consider
this patch:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://gist.github.com/66038&quot;&gt;http://gist.github.com/66038&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It's just a proof-of-concept, may need some cleaning up and
adding tests/merging w/ coderrr's patch.&lt;/p&gt;
&lt;p&gt;What do you think?&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-17T22:48:38+00:00</created-at>
      <creator-id type="integer">37814</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1752</number>
      <permalink>added-using_connection-method-like-with_connection-but-sets-it-as-default-connection-while-inside-the-block</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>activerecord connection patch pool</tag>
      <title>Adding cleanup_connection method</title>
      <updated-at type="datetime">2009-02-17T22:48:41+00:00</updated-at>
      <user-id type="integer">17057</user-id>
      <user-name>Nick Sieger</user-name>
      <creator-name>coderrr</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1752</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">5</attachments-count>
      <body>Hey nick

The only issue with that is that if you have multiple connections (in different AR models) you'd need to do a connection call for each of them.  If you forgot to do that these connections would remain open in the thread.

User.connection { Project.connection { ... } }

Not that big deal.  Other than that I don't really have any objection to piggybacking.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Hey nick&lt;/p&gt;
&lt;p&gt;The only issue with that is that if you have multiple
connections (in different AR models) you'd need to do a connection
call for each of them. If you forgot to do that these connections
would remain open in the thread.&lt;/p&gt;
&lt;p&gt;User.connection { Project.connection { ... } }&lt;/p&gt;
&lt;p&gt;Not that big deal. Other than that I don't really have any
objection to piggybacking.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-17T23:01:59+00:00</created-at>
      <creator-id type="integer">37814</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1752</number>
      <permalink>added-using_connection-method-like-with_connection-but-sets-it-as-default-connection-while-inside-the-block</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>activerecord connection patch pool</tag>
      <title>Adding cleanup_connection method</title>
      <updated-at type="datetime">2009-02-17T23:02:01+00:00</updated-at>
      <user-id type="integer">37814</user-id>
      <user-name>coderrr</user-name>
      <creator-name>coderrr</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1752</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">5</attachments-count>
      <body>If you're satisfied with that pattern, we could push the logic up to the AR::Base class method to do the cleanup and it could do so with clear_active_connections! like you have in your patch.

Any other thoughts about the overloading of AR::Base.connection?</body>
      <body-html>&lt;div&gt;&lt;p&gt;If you're satisfied with that pattern, we could push the logic
up to the AR::Base class method to do the cleanup and it could do
so with clear_active_connections! like you have in your patch.&lt;/p&gt;
&lt;p&gt;Any other thoughts about the overloading of
AR::Base.connection?&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-18T01:48:12+00:00</created-at>
      <creator-id type="integer">37814</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1752</number>
      <permalink>added-using_connection-method-like-with_connection-but-sets-it-as-default-connection-while-inside-the-block</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>activerecord connection patch pool</tag>
      <title>Adding cleanup_connection method</title>
      <updated-at type="datetime">2009-02-18T01:48:16+00:00</updated-at>
      <user-id type="integer">17057</user-id>
      <user-name>Nick Sieger</user-name>
      <creator-name>coderrr</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1752</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">5</attachments-count>
      <body>Here's a patch w/ coderrr's tests and my approach with passing the block down through AR::Base.connection.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Here's a patch w/ coderrr's tests and my approach with passing
the block down through AR::Base.connection.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-18T20:28:48+00:00</created-at>
      <creator-id type="integer">37814</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1752</number>
      <permalink>added-using_connection-method-like-with_connection-but-sets-it-as-default-connection-while-inside-the-block</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>activerecord connection patch pool</tag>
      <title>Adding cleanup_connection method</title>
      <updated-at type="datetime">2009-02-18T20:28:50+00:00</updated-at>
      <user-id type="integer">17057</user-id>
      <user-name>Nick Sieger</user-name>
      <creator-name>coderrr</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1752</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">6</attachments-count>
      <body>Don't we already have a with_connection method on the connection pool?

Perhaps we just make that available from AR::Base more simply?</body>
      <body-html>&lt;div&gt;&lt;p&gt;Don't we already have a with_connection method on the connection
pool?&lt;/p&gt;
&lt;p&gt;Perhaps we just make that available from AR::Base more
simply?&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-18T20:52:19+00:00</created-at>
      <creator-id type="integer">37814</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1752</number>
      <permalink>added-using_connection-method-like-with_connection-but-sets-it-as-default-connection-while-inside-the-block</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>activerecord connection patch pool</tag>
      <title>Adding cleanup_connection method</title>
      <updated-at type="datetime">2009-02-18T20:52:23+00:00</updated-at>
      <user-id type="integer">141</user-id>
      <user-name>Michael Koziarski</user-name>
      <creator-name>coderrr</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1752</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">6</attachments-count>
      <body>with_connection isn't good enough.  It only releases the connection which it checks out.  And the connection it checks out will be different from AR::B#connection</body>
      <body-html>&lt;div&gt;&lt;p&gt;with_connection isn't good enough. It only releases the
connection which it checks out. And the connection it checks out
will be different from AR::B#connection&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-18T20:55:11+00:00</created-at>
      <creator-id type="integer">37814</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1752</number>
      <permalink>added-using_connection-method-like-with_connection-but-sets-it-as-default-connection-while-inside-the-block</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>activerecord connection patch pool</tag>
      <title>Adding cleanup_connection method</title>
      <updated-at type="datetime">2009-02-18T20:55:12+00:00</updated-at>
      <user-id type="integer">37814</user-id>
      <user-name>coderrr</user-name>
      <creator-name>coderrr</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1752</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">6</attachments-count>
      <body>+1</body>
      <body-html>&lt;div&gt;&lt;p&gt;+1&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-19T14:36:40+00:00</created-at>
      <creator-id type="integer">37814</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1752</number>
      <permalink>added-using_connection-method-like-with_connection-but-sets-it-as-default-connection-while-inside-the-block</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>activerecord connection patch pool</tag>
      <title>Adding cleanup_connection method</title>
      <updated-at type="datetime">2009-02-19T14:36:46+00:00</updated-at>
      <user-id type="integer">22242</user-id>
      <user-name>Dan Pickett</user-name>
      <creator-name>coderrr</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1752</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">6</attachments-count>
      <body>Koz: with_connection doesn't associate the connection with the thread, so that regular code like Model.find would still pull another connection. That's yet another option to make with_connection stash the connection away in the thread if it isn't there.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Koz: with_connection doesn't associate the connection with the
thread, so that regular code like Model.find would still pull
another connection. That's yet another option to make
with_connection stash the connection away in the thread if it isn't
there.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-19T17:04:39+00:00</created-at>
      <creator-id type="integer">37814</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1752</number>
      <permalink>added-using_connection-method-like-with_connection-but-sets-it-as-default-connection-while-inside-the-block</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>activerecord connection patch pool</tag>
      <title>Adding cleanup_connection method</title>
      <updated-at type="datetime">2009-02-19T17:04:41+00:00</updated-at>
      <user-id type="integer">17057</user-id>
      <user-name>Nick Sieger</user-name>
      <creator-name>coderrr</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1752</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">6</attachments-count>
      <body>Just seems to me like unless there's a reason that with_connection
*shouldn't* do that, then it'd be cleaner than messing with
.connection

What's the behaviour of this new method if a connection is already
checked out, does it check out another and replace all the thread
locals?</body>
      <body-html>&lt;div&gt;&lt;p&gt;Just seems to me like unless there's a reason that
with_connection &lt;em&gt;shouldn't&lt;/em&gt; do that, then it'd be cleaner
than messing with .connection&lt;/p&gt;
&lt;p&gt;What's the behaviour of this new method if a connection is
already checked out, does it check out another and replace all the
thread locals?&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-19T19:01:59+00:00</created-at>
      <creator-id type="integer">37814</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1752</number>
      <permalink>added-using_connection-method-like-with_connection-but-sets-it-as-default-connection-while-inside-the-block</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>activerecord connection patch pool</tag>
      <title>Adding cleanup_connection method</title>
      <updated-at type="datetime">2009-02-19T19:02:00+00:00</updated-at>
      <user-id type="integer">141</user-id>
      <user-name>Michael Koziarski</user-name>
      <creator-name>coderrr</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1752</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">6</attachments-count>
      <body>Well there are two versions...

In the original version (cleanup_connection method), if a connection is already checked out it won't check out a new one.  But will release it when the block completes.

In the latest version it wouldn't check out a new connection either but also wouldn't release the connection afterwards.

I don't have a problem with putting the functionality in with_connection.  I agree changing connection method is a heavier change, even though without a block it would function as before.  I really don't care where this functionality ends up, but at this point if I had to vote, it seems that modifying the connection method would be cleanest and point people in the right direction in terms of checkins/checkout.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Well there are two versions...&lt;/p&gt;
&lt;p&gt;In the original version (cleanup_connection method), if a
connection is already checked out it won't check out a new one. But
will release it when the block completes.&lt;/p&gt;
&lt;p&gt;In the latest version it wouldn't check out a new connection
either but also wouldn't release the connection afterwards.&lt;/p&gt;
&lt;p&gt;I don't have a problem with putting the functionality in
with_connection. I agree changing connection method is a heavier
change, even though without a block it would function as before. I
really don't care where this functionality ends up, but at this
point if I had to vote, it seems that modifying the connection
method would be cleanest and point people in the right direction in
terms of checkins/checkout.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-19T19:10:54+00:00</created-at>
      <creator-id type="integer">37814</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1752</number>
      <permalink>added-using_connection-method-like-with_connection-but-sets-it-as-default-connection-while-inside-the-block</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>activerecord connection patch pool</tag>
      <title>Adding cleanup_connection method</title>
      <updated-at type="datetime">2009-02-19T19:10:58+00:00</updated-at>
      <user-id type="integer">37814</user-id>
      <user-name>coderrr</user-name>
      <creator-name>coderrr</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1752</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">6</attachments-count>
      <body>I've noticed that ActiveRecord::Base.connection_pool.with_connection doesn't override the connection for all your models... 

If you plan to

  ActiveRecord::Base.connection_pool.with_connection do |conn|
    u = User.new
    u.save!
  end

then your user object is not saved with the connection you opened with_connection.  Instead you have to do:

  User.connection_pool.with_connection do |conn|
    u = User.new
    u.save!
  end

Is this by design? Why?

If we change is_connection to:

      def with_connection
        conn = checkout
        old_conn = @reserved_connections[current_connection_id]
        @reserved_connections[current_connection_id] = conn
        yield conn
      ensure
        checkin conn
        @reserved_connections[current_connection_id] = old_conn
      end


Then it works as I had expected it should.</body>
      <body-html>&lt;div&gt;&lt;p&gt;I've noticed that
ActiveRecord::Base.connection_pool.with_connection doesn't override
the connection for all your models...&lt;/p&gt;
&lt;p&gt;If you plan to&lt;/p&gt;
&lt;p&gt;ActiveRecord::Base.connection_pool.with_connection do |conn|&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;u = User.new
u.save!
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;end&lt;/p&gt;
&lt;p&gt;then your user object is not saved with the connection you
opened with_connection. Instead you have to do:&lt;/p&gt;
&lt;p&gt;User.connection_pool.with_connection do |conn|&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;u = User.new
u.save!
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;end&lt;/p&gt;
&lt;p&gt;Is this by design? Why?&lt;/p&gt;
&lt;p&gt;If we change is_connection to:&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;  def with_connection
    conn = checkout
    old_conn = @reserved_connections[current_connection_id]
    @reserved_connections[current_connection_id] = conn
    yield conn
  ensure
    checkin conn
    @reserved_connections[current_connection_id] = old_conn
  end
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;Then it works as I had expected it should.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-26T16:01:23+00:00</created-at>
      <creator-id type="integer">37814</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1752</number>
      <permalink>added-using_connection-method-like-with_connection-but-sets-it-as-default-connection-while-inside-the-block</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>activerecord connection patch pool</tag>
      <title>Adding cleanup_connection method</title>
      <updated-at type="datetime">2009-02-26T16:01:29+00:00</updated-at>
      <user-id type="integer">15613</user-id>
      <user-name>Jacob Burkhart</user-name>
      <creator-name>coderrr</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1752</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">6</attachments-count>
      <body>Yes, the issue you pointed out is exactly why I created this ticket.

We need more than what your implementation of with_connection provides.  If you have nested calls to with_connection you'll check out a new connection for each one where you really want to be using the same connection throughout all of the calls.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Yes, the issue you pointed out is exactly why I created this
ticket.&lt;/p&gt;
&lt;p&gt;We need more than what your implementation of with_connection
provides. If you have nested calls to with_connection you'll check
out a new connection for each one where you really want to be using
the same connection throughout all of the calls.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-26T16:08:04+00:00</created-at>
      <creator-id type="integer">37814</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1752</number>
      <permalink>added-using_connection-method-like-with_connection-but-sets-it-as-default-connection-while-inside-the-block</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>activerecord connection patch pool</tag>
      <title>Adding cleanup_connection method</title>
      <updated-at type="datetime">2009-02-26T16:08:07+00:00</updated-at>
      <user-id type="integer">37814</user-id>
      <user-name>coderrr</user-name>
      <creator-name>coderrr</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1752</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">6</attachments-count>
      <body>I've moved the functionality to with_connection per Koz's suggestion.

If a connection exists with_connection will simply yield the connection.
If a connection doesn't exist with_connection will call connection which will checkout a connection and set it as the current connection, yield it, and ensure it's checked in after the block finishes.

This ensures that any nested with_connection calls won't check out multiple connections.

... And it doesn't increase the # of lines of the with_connection method :)</body>
      <body-html>&lt;div&gt;&lt;p&gt;I've moved the functionality to with_connection per Koz's
suggestion.&lt;/p&gt;
&lt;p&gt;If a connection exists with_connection will simply yield the
connection. If a connection doesn't exist with_connection will call
connection which will checkout a connection and set it as the
current connection, yield it, and ensure it's checked in after the
block finishes.&lt;/p&gt;
&lt;p&gt;This ensures that any nested with_connection calls won't check
out multiple connections.&lt;/p&gt;
&lt;p&gt;... And it doesn't increase the # of lines of the
with_connection method :)&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-03-11T23:06:07+00:00</created-at>
      <creator-id type="integer">37814</creator-id>
      <diffable-attributes type="yaml">--- 
:title: Adding cleanup_connection method
</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1752</number>
      <permalink>added-using_connection-method-like-with_connection-but-sets-it-as-default-connection-while-inside-the-block</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>activerecord connection patch pool</tag>
      <title>Modifying with_connection method</title>
      <updated-at type="datetime">2009-03-11T23:06:10+00:00</updated-at>
      <user-id type="integer">37814</user-id>
      <user-name>coderrr</user-name>
      <creator-name>coderrr</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1752</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">141</assigned-user-id>
      <attachments-count type="integer">7</attachments-count>
      <body></body>
      <body-html></body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-03-12T00:34:02+00:00</created-at>
      <creator-id type="integer">37814</creator-id>
      <diffable-attributes type="yaml">--- 
:assigned_user: 1366
</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1752</number>
      <permalink>added-using_connection-method-like-with_connection-but-sets-it-as-default-connection-while-inside-the-block</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>activerecord connection patch pool</tag>
      <title>Modifying with_connection method</title>
      <updated-at type="datetime">2009-03-12T00:34:04+00:00</updated-at>
      <user-id type="integer">1366</user-id>
      <user-name>Pratik</user-name>
      <creator-name>coderrr</creator-name>
      <assigned-user-name>Michael Koziarski</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1752</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">141</assigned-user-id>
      <attachments-count type="integer">7</attachments-count>
      <body>So what's the deal?  Do you have any response Koz?</body>
      <body-html>&lt;div&gt;&lt;p&gt;So what's the deal? Do you have any response Koz?&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-04-29T04:50:41+01:00</created-at>
      <creator-id type="integer">37814</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1752</number>
      <permalink>added-using_connection-method-like-with_connection-but-sets-it-as-default-connection-while-inside-the-block</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>activerecord connection patch pool</tag>
      <title>Modifying with_connection method</title>
      <updated-at type="datetime">2009-04-29T04:50:46+01:00</updated-at>
      <user-id type="integer">37814</user-id>
      <user-name>coderrr</user-name>
      <creator-name>coderrr</creator-name>
      <assigned-user-name>Michael Koziarski</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1752</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">141</assigned-user-id>
      <attachments-count type="integer">7</attachments-count>
      <body>(from [5501b99a19a2a67a9a920fd3c7bff071a2ecf058]) Ensure ActiveRecord::Base.connection_pool.with_connection creates a new connection only when needed [#1752 state:resolved]

Signed-off-by: Pratik Naik &lt;pratiknaik@gmail.com&gt;
http://github.com/rails/rails/commit/5501b99a19a2a67a9a920fd3c7bff071a2ecf058</body>
      <body-html>&lt;div&gt;&lt;p&gt;(from [5501b99a19a2a67a9a920fd3c7bff071a2ecf058]) Ensure
ActiveRecord::Base.connection_pool.with_connection creates a new
connection only when needed [&lt;a href=&quot;/projects/8994/tickets/1752&quot; title=&quot;Ticket #1752&quot;&gt;#1752&lt;/a&gt; state:resolved]&lt;/p&gt;
&lt;p&gt;Signed-off-by: Pratik Naik &lt;a href=&quot;mailto:pratiknaik@gmail.com&quot;&gt;pratiknaik@gmail.com&lt;/a&gt; &lt;a href=&quot;http://github.com/rails/rails/commit/5501b99a19a2a67a9a920fd3c7bff071a2ecf058&quot;&gt;
http://github.com/rails/rails/co...&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-05-01T14:58:50+01:00</created-at>
      <creator-id type="integer">37814</creator-id>
      <diffable-attributes type="yaml">--- 
:state: new
</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1752</number>
      <permalink>added-using_connection-method-like-with_connection-but-sets-it-as-default-connection-while-inside-the-block</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>activerecord connection patch pool</tag>
      <title>Modifying with_connection method</title>
      <updated-at type="datetime">2009-05-01T14:58:51+01:00</updated-at>
      <user-id type="integer">17393</user-id>
      <user-name>Repository</user-name>
      <creator-name>coderrr</creator-name>
      <assigned-user-name>Michael Koziarski</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1752</url>
      <milestone-title>2.x</milestone-title>
    </version>
  </versions>
  <attachments type="array">
    <attachment type="Attachment">
      <code>fb4179bf45ebf635a92fa3855aed5bafc075a2b4</code>
      <content-type>text/plain</content-type>
      <created-at type="datetime">2009-01-13T22:36:38+00:00</created-at>
      <filename>using_connection.diff</filename>
      <height type="integer" nil="true"></height>
      <id type="integer">78080</id>
      <size type="integer">2921</size>
      <uploader-id type="integer">37814</uploader-id>
      <width type="integer" nil="true"></width>
      <url>http://rails.lighthouseapp.com/attachments/78080/using_connection.diff</url>
    </attachment>
    <attachment type="Attachment">
      <code>de802c4f48910b48c79b8fe2b0d3417ec2de057e</code>
      <content-type>text/plain</content-type>
      <created-at type="datetime">2009-01-14T19:58:42+00:00</created-at>
      <filename>cleanup_connection.diff</filename>
      <height type="integer" nil="true"></height>
      <id type="integer">78449</id>
      <size type="integer">3287</size>
      <uploader-id type="integer">37814</uploader-id>
      <width type="integer" nil="true"></width>
      <url>http://rails.lighthouseapp.com/attachments/78449/cleanup_connection.diff</url>
    </attachment>
    <attachment type="Attachment">
      <code>da8846150cf32d8cf467ebd685264597d03fa241</code>
      <content-type>text/plain</content-type>
      <created-at type="datetime">2009-01-14T22:03:34+00:00</created-at>
      <filename>cleanup_connection.diff</filename>
      <height type="integer" nil="true"></height>
      <id type="integer">78514</id>
      <size type="integer">3912</size>
      <uploader-id type="integer">37814</uploader-id>
      <width type="integer" nil="true"></width>
      <url>http://rails.lighthouseapp.com/attachments/78514/cleanup_connection.diff</url>
    </attachment>
    <attachment type="Attachment">
      <code>c524e36e8adcb2bd5bc1cc7511430df504b58ee1</code>
      <content-type>text/plain</content-type>
      <created-at type="datetime">2009-01-14T22:05:42+00:00</created-at>
      <filename>cleanup_connection.diff</filename>
      <height type="integer" nil="true"></height>
      <id type="integer">78515</id>
      <size type="integer">3918</size>
      <uploader-id type="integer">37814</uploader-id>
      <width type="integer" nil="true"></width>
      <url>http://rails.lighthouseapp.com/attachments/78515/cleanup_connection.diff</url>
    </attachment>
    <attachment type="Attachment">
      <code>5bdc933f7fbed25ba95592e0c9a651cbdb76f6bb</code>
      <content-type>text/plain</content-type>
      <created-at type="datetime">2009-02-17T21:31:53+00:00</created-at>
      <filename>cleanup_connection.diff</filename>
      <height type="integer" nil="true"></height>
      <id type="integer">89843</id>
      <size type="integer">4880</size>
      <uploader-id type="integer">37814</uploader-id>
      <width type="integer" nil="true"></width>
      <url>http://rails.lighthouseapp.com/attachments/89843/cleanup_connection.diff</url>
    </attachment>
    <attachment type="Attachment">
      <code>389ca6c7e07f85be838f6e8042095c7f16b1bb92</code>
      <content-type>text/plain</content-type>
      <created-at type="datetime">2009-02-18T20:28:48+00:00</created-at>
      <filename>0001-Allow-AR-Base.connection-to-take-a-block-meaning-cl.patch</filename>
      <height type="integer" nil="true"></height>
      <id type="integer">90283</id>
      <size type="integer">6645</size>
      <uploader-id type="integer">17057</uploader-id>
      <width type="integer" nil="true"></width>
      <url>http://rails.lighthouseapp.com/attachments/90283/0001-Allow-AR-Base.connection-to-take-a-block-meaning-cl.patch</url>
    </attachment>
    <attachment type="Attachment">
      <code>0d6878b2888d2473e0a0e942652ca97392c71204</code>
      <content-type>text/plain</content-type>
      <created-at type="datetime">2009-03-11T23:06:07+00:00</created-at>
      <filename>with_connection.diff</filename>
      <height type="integer" nil="true"></height>
      <id type="integer">98847</id>
      <size type="integer">3840</size>
      <uploader-id type="integer">37814</uploader-id>
      <width type="integer" nil="true"></width>
      <url>http://rails.lighthouseapp.com/attachments/98847/with_connection.diff</url>
    </attachment>
  </attachments>
</ticket>
