damil/DBIx-DataModel — pull request #5 by asolovey (2013-06-14 20:02:49+00:00)
Title: Workaround for DBI warnings about active statement handles when using dbi_prepare_method => prepare_cached

We're using DBIx::DataModel with dbi_prepare_method => 'prepare_cached'. Unfortnately, DBI complains about "statement handles still Active" on `fetch()` and `insert( -returning => ... )` operations. This is caused by the fact that `$sth` remains active unless `fetchrow_*` is called in a loop until it returns false, or `$sth->finish` is called explicitly. Both `fetch()` and `insert( -returning => ... )` use a single `fetchrow_array` without a loop or `finish()` and their statement remains active, so when prepare_cached is used again for the same query, DBI issues a warning.

I've added a simple workaround, which calls `$sth->finish()` in statement returning the first row only and in insert.