[Dbix-class] Get generated SQL
Matt Lawrence
matt.lawrence at ymogen.net
Mon Mar 10 11:00:43 GMT 2008
Matt S Trout wrote:
> On Tue, Feb 26, 2008 at 12:58:20PM +0000, Matt Lawrence wrote:
>
>> Emmanuel Quevillon wrote:
>>
>>> Hi,
>>>
>>> Is there a simple way to get the automatic generated SQL from a
>>> ResultSet? As for example $query = $rs->sql()?
>>> Thanks
>>>
>>>
>> I wrote a patch to achieve this a little while ago, but I didn't get
>> around to writing good enough tests. Since someone else seems to want
>> the feature I may as well share it.
>>
>> It's a patch against CPAN version 0.08008, which I haven't checked
>> against later versions. It doesn't cause any test failures on my system,
>> although I didn't run all the optional tests.
>>
>> It provides a method called as_sql() on the cursor, which is proxied
>> from the resultset.
>>
>
> Interesting.
>
> Have you considered writing some code to interpolate the bind parameters?
>
> For copy+paste into an SQL CLI prompt it's a bit inconvenient to substitute
> the ?s manually.
>
I was contemplating it, but never got around to it.
> (we're currently rounding up for 0.8100, so if somebody gets a patch like
> this together in the next week or so with tests you've a good chance of
> it being applied)
>
>
I'll see if I can find some time this week(end) to finish it off then.
Where would you recommend the tests to go?
Matt
More information about the DBIx-Class
mailing list