Class: XMigra::MSSQLSpecifics::StatisticsObject

Inherits:
Object
  • Object
show all
Defined in:
lib/xmigra/db_support/mssql.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, params) ⇒ StatisticsObject

Returns a new instance of StatisticsObject.



19
20
21
22
23
24
25
26
# File 'lib/xmigra/db_support/mssql.rb', line 19

def initialize(name, params)
  (@name = name.dup).freeze
  (@target = params[0].dup).freeze
  (@columns = params[1].dup).freeze
  @options = params[2] || {}
  @options.freeze
  @options.each_value {|v| v.freeze}
end

Instance Attribute Details

#columnsObject (readonly)

Returns the value of attribute columns.



28
29
30
# File 'lib/xmigra/db_support/mssql.rb', line 28

def columns
  @columns
end

#nameObject (readonly)

Returns the value of attribute name.



28
29
30
# File 'lib/xmigra/db_support/mssql.rb', line 28

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



28
29
30
# File 'lib/xmigra/db_support/mssql.rb', line 28

def options
  @options
end

#targetObject (readonly)

Returns the value of attribute target.



28
29
30
# File 'lib/xmigra/db_support/mssql.rb', line 28

def target
  @target
end

Instance Method Details

#creation_sqlObject



30
31
32
33
34
35
36
37
38
# File 'lib/xmigra/db_support/mssql.rb', line 30

def creation_sql
  result = "CREATE STATISTICS #{name} ON #{target} (#{columns})"
  
  result += " WHERE " + @options['where'] if @options['where']
  result += " WITH " + @options['with'] if @options['with']
  
  result += ";"
  return result
end