Class: Sequel::LoadDataInfileExpression Private

Inherits:
Object
  • Object
show all
Defined in:
lib/sequel/load_data_infile.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, table, columns, opts = {}) ⇒ LoadDataInfileExpression

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of LoadDataInfileExpression.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/sequel/load_data_infile.rb', line 8

def initialize(path, table, columns, opts={})
  @path    = path
  @table   = table
  @columns = columns
  @ignore  = opts[:ignore]
  @update  = opts[:update]
  @set     = opts[:set] || {}
  @character_set = opts[:character_set] || "utf8"
  if opts[:format] == :csv
    @field_terminator = ","
    @enclosed_by = '"'
    @escaped_by = '"'
  end
end

Instance Attribute Details

#character_setObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



6
7
8
# File 'lib/sequel/load_data_infile.rb', line 6

def character_set
  @character_set
end

#columnsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



6
7
8
# File 'lib/sequel/load_data_infile.rb', line 6

def columns
  @columns
end

#ignoreObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



6
7
8
# File 'lib/sequel/load_data_infile.rb', line 6

def ignore
  @ignore
end

#pathObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



6
7
8
# File 'lib/sequel/load_data_infile.rb', line 6

def path
  @path
end

#tableObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



6
7
8
# File 'lib/sequel/load_data_infile.rb', line 6

def table
  @table
end

Instance Method Details

#ignore?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


27
28
29
# File 'lib/sequel/load_data_infile.rb', line 27

def ignore?
  @update == :ignore
end

#replace?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


23
24
25
# File 'lib/sequel/load_data_infile.rb', line 23

def replace?
  @update == :replace
end

#to_sql(db) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/sequel/load_data_infile.rb', line 31

def to_sql(db)
  @db = db
  
  [load_fragment,
   replace_fragment,
   table_fragment,
   character_set_fragment,
   field_terminator_fragment,
   field_enclosure_fragment,
   escape_fragment,
   ignore_fragment, 
   column_fragment,
   set_fragment].compact.join(" ")
end