Sha256: ee6bb6c8d32b1596ff708caa14f5683153a3a27fafc9058286c968541f8e0a34

Contents?: true

Size: 1012 Bytes

Versions: 1

Compression:

Stored size: 1012 Bytes

Contents

require 'spec_helper'

describe Chicago::ETL::SequelExtensions::LoadDataInfile do
  before :each do
    @sql = TEST_DB[:foo].load_csv_infile_sql("bar.csv", [:bar, :baz])
  end

  it "loads the data in the file" do
    @sql.should include("LOAD DATA INFILE 'bar.csv'")
  end

  it "replaces rows currently in the table" do
    @sql.should include("REPLACE INTO TABLE `foo`")
  end

  it "should be in the UTF 8 character set" do
    @sql.should include("CHARACTER SET 'utf8'")
  end

  it "should escape with the \" character" do
    @sql.should include("ESCAPED BY '\"'")
  end

  it "supports standard csv, with optional quoting" do
    @sql.should include("FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"'")
  end

  it "loads into the columns specified" do
    @sql.should include("(`bar`,`baz`);")
  end

  it "can ignore instead of replacing rows" do
    @sql = TEST_DB[:foo].insert_ignore.
      load_csv_infile_sql("bar.csv", [:bar, :baz])
    @sql.should include("IGNORE INTO TABLE `foo`")
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chicago-etl-0.0.9 spec/etl/sequel/load_data_infile_spec.rb