Module: StackDeck::Frame::Postgres
- Defined in:
- lib/stackdeck/postgres.rb
Defined Under Namespace
Classes: Function
Class Method Summary collapse
Class Method Details
.extract(ex, conn = nil) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/stackdeck/postgres.rb', line 44 def self.extract(ex, conn=nil) postgres_stack = [] if ex.internal_query postgres_stack << Frame::SQL.from_char(ex.internal_query, ex.internal_position) end if ex.context postgres_stack.concat ex.context.split(/\n/).map {|s| parse(s, conn) } end if ex.query postgres_stack << Frame::SQL.from_char(ex.query, ex.query_position) end end |
.parse(str, conn = nil) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/stackdeck/postgres.rb', line 57 def self.parse(str, conn=nil) if str =~ /([^"]+) "(.*)"(?: line (\d+))?(?: (at [^"]+))?$/ case $1 when 'SQL statement' Frame::SQL.new($2) else f = $1.empty? ? nil : $1 self::Function.new(conn, f, $2, $3.to_i, $4) end end end |