我可以漂亮的打印DBIx :: Class中的DBIC_TRACE输出吗? [英] Can I pretty-print the DBIC_TRACE output in DBIx::Class?
问题描述
$ $ p
$ {$ ENV {DBIC_TRACE} = 1}
会生成非常有用的输出,尤其是显示正在执行的SQL查询,但SQL查询全部在同一行上。 / p>
是否有办法通过某种sql tidy例程来更好地对其进行格式化,也许将其分解为多行?如果没有,任何人都可以给我一个微弱的代码,我需要破解添加这样一个钩子?什么最好的工具是接受一个格式不正确的SQL查询,并推出一个很好格式化的?
在这个上下文中nice格式化只是比all on一条线。我不特别讨论格式化查询的具体样式
谢谢!
从DBIx :: Class 0.08124开始,它是内置的。
只需将 $ ENV {DBIC_TRACE_PROFILE}
设置为控制台
或 console_monochrome
。
Setting the DBIC_TRACE environment variable to true:
BEGIN { $ENV{DBIC_TRACE} = 1 }
generates very helpful output, especially showing the SQL query that is being executed, but the SQL query is all on one line.
Is there a way to push it through some kinda "sql tidy" routine to format it better, perhaps breaking it up over multiple lines? Failing that, could anyone give me a nudge into where in the code I'd need to hack to add such a hook? And what the best tool is to accept a badly formatted SQL query and push out a nicely formatted one?
"nice formatting" in this context simply means better than "all on one line". I'm not particularly fussed about specific styles of formatting queries
Thanks!
As of DBIx::Class 0.08124 it's built in.
Just set $ENV{DBIC_TRACE_PROFILE}
to console
or console_monochrome
.
这篇关于我可以漂亮的打印DBIx :: Class中的DBIC_TRACE输出吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!