Class: Roebe::SqlParadise::CreateTable

Inherits:
SQL_Command show all
Defined in:
lib/roebe/sql_paradise/create_table.rb

Overview

Roebe::SqlParadise::CreateTable

Constant Summary collapse

REMOVE_NEWLINES =
#

REMOVE_NEWLINES

#
true

Class Method Summary collapse

Methods inherited from SQL_Command

#sanitize

Class Method Details

.[](name_of_table = :nodes, values = 'tax_id int, parent_tax_id int, rank varchar(50)') ⇒ Object

#

CreateTable[]

Use this class method to generate a proper CREATE TABLE statement.

This method will return a String such as “CREATE TABLE nodes ( tax_id int, parent_tax_id int, rank varchar(50) );”

#


30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/roebe/sql_paradise/create_table.rb', line 30

def self.[](
    name_of_table = :nodes,
    values        = 'tax_id int, parent_tax_id int, rank varchar(50)'
  )
  name_of_table = SQL_Command.new.sanitize(name_of_table.to_s)
  values = SQL_Command.new.sanitize(values.to_s)
  _ = <<EOF
CREATE TABLE #{name_of_table} ( #{values} );
EOF
  _.delete!("\n") if REMOVE_NEWLINES
  return _.chomp
end