title: ruby, wrong number of columns attempting to import csv into in-memory database
body: <p>I have a problem when I'm trying to import data from a file into a database for a test. The following code does exactly as I expect, in the Ruby shell:</p>
  
  <pre><code>jruby-1.7.4 :001 &gt; require('sequel')
   =&gt; true
  jruby-1.7.4 :002 &gt; require('csv')
   =&gt; true
  jruby-1.7.4 :003 &gt; file = CSV.read('./spec/test_data/registration_sessions.csv')
   =&gt; [["01", "EG000000001"], ["02", "EG000000002"], ["03", "EG000000002"]]
  jruby-1.7.4 :004 &gt; db = Sequel.connect('jdbc:sqlite::memory:')
   =&gt; #&lt;Sequel::JDBC::Database: "jdbc:sqlite::memory:"&gt;
  jruby-1.7.4 :005 &gt; db.create_table(:registration_sessions) do
  jruby-1.7.4 :006 &gt;   Integer :id
  jruby-1.7.4 :007?&gt;   String :device_serial
  jruby-1.7.4 :008?&gt; end
   =&gt; nil
  jruby-1.7.4 :009 &gt; db[:registration_sessions]
   =&gt; #&lt;Sequel::JDBC::Dataset: "SELECT * FROM `registration_sessions`"&gt;
  jruby-1.7.4 :010 &gt; db[:registration_sessions].import(db[:registration_sessions].columns, file)
   =&gt; ["INSERT INTO `registration_sessions` (`id`, `device_serial`) VALUES ('01', 'EG000000001')", "INSERT INTO `registration_sessions` (`id`, `device_serial`) VALUES ('02', 'EG000000002')", "INSERT INTO `registration_sessions` (`id`, `device_serial`) VALUES ('03', 'EG000000002')"]
  jruby-1.7.4 :012 &gt; db[:registration_sessions].all
   =&gt; [{:id=&gt;1, :device_serial=&gt;"EG000000001"}, {:id=&gt;2, :device_serial=&gt;"EG000000002"}, {:id=&gt;3, :device_serial=&gt;"EG000000002"}]
  </code></pre>
  
  <p>But in my test, things don't go as expected:</p>
  
  <pre><code>let(:registration_metrics_db) { create_registration_metrics_db }
  let(:session_seed_data) { CSV.read('./spec/test_data/registration_sessions.csv') }
  
  before(:each) do
      seed_test_data(registration_metrics_db[:registration_sessions], session_seed_data)
  end
  
  def create_registration_metrics_db
    db = Sequel.connect('jdbc:sqlite::memory:')
  
    db.create_table(:registration_sessions) do
      Integer :id
      String :device_serial
    end
  
    db
  end
  
  def seed_test_data(table, data)
    table.import(table.columns, data)
  end
  </code></pre>
  
  <p>Which leads to the following, when I run my tests:</p>
  
  <pre><code>  14) RegistrationMetricsQueries #get_registration_metrics should return only durations for sessions that contain the start and end moment
       Failure/Error: seed_test_data(registration_metrics_db[:registration_sessions], session_seed_data)
       Sequel::Error:
         Different number of values and columns given to insert_sql
       # ./spec/services/tablet_usage_queries_spec.rb:88:in `seed_test_data'
       # ./spec/services/registration_metrics_queries_spec.rb:10:in `(root)'
  
    15) RegistrationMetricsQueries #get_registration_metrics should return durations in seconds for valid registration sessions, which contain the start and end moment
       Failure/Error: seed_test_data(registration_metrics_db[:registration_sessions], session_seed_data)
       Sequel::Error:
         Different number of values and columns given to insert_sql
       # ./spec/services/tablet_usage_queries_spec.rb:88:in `seed_test_data'
       # ./spec/services/registration_metrics_queries_spec.rb:10:in `(root)'
  </code></pre>
  
  <p>Am I doing it wrong?</p>
  
  <p>edit: oh, and my sample data</p>
  
  <pre><code>01,EG000000001
  02,EG000000002
  03,EG000000002
  </code></pre>