Class: Gitlab::Database::QueryAnalyzer::Parsed

Inherits:
Object
  • Object
show all
Includes:
Utils::StrongMemoize
Defined in:
lib/gitlab/database/query_analyzer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw, connection, event_name, cached) ⇒ Parsed

Returns a new instance of Parsed.



18
19
20
21
22
23
24
# File 'lib/gitlab/database/query_analyzer.rb', line 18

def initialize(raw, connection, event_name, cached)
  @raw = raw
  @connection = connection
  @event_name = normalize_event_name(event_name)
  @cached = cached
  @error = nil
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



16
17
18
# File 'lib/gitlab/database/query_analyzer.rb', line 16

def connection
  @connection
end

#errorObject (readonly)

Returns the value of attribute error.



16
17
18
# File 'lib/gitlab/database/query_analyzer.rb', line 16

def error
  @error
end

#event_nameObject (readonly)

Returns the value of attribute event_name.



16
17
18
# File 'lib/gitlab/database/query_analyzer.rb', line 16

def event_name
  @event_name
end

#rawObject (readonly)

Returns the value of attribute raw.



16
17
18
# File 'lib/gitlab/database/query_analyzer.rb', line 16

def raw
  @raw
end

Instance Method Details

#cached?Boolean

Returns true if the query was using the ActiveRecord Query Cache

Returns:

  • (Boolean)


27
28
29
# File 'lib/gitlab/database/query_analyzer.rb', line 27

def cached?
  !!@cached
end

#pgObject



38
39
40
41
42
# File 'lib/gitlab/database/query_analyzer.rb', line 38

def pg
  try_parse do
    PgQuery.parse(raw)
  end
end

#sqlObject



31
32
33
34
35
# File 'lib/gitlab/database/query_analyzer.rb', line 31

def sql
  try_parse do
    PgQuery.normalize(raw)
  end
end