title: Rails database boolean values
body: <p>Code first:</p>
  
  <pre><code>create_table :users do |t|
    ...
    t.boolean :is_active, :default =&gt; true
    ...
  end
  </code></pre>
  
  <p>Now, here is my issue - I am creating a rake task to import a LARGE number of records (10,000+). I've done extensive testing and benchmarking and determined that the fastest and most efficient way to perform this task is to create one giant raw SQL statement. (I'm reading data from CSV). As an example:</p>
  
  <pre><code>inserts = Array.new
  FasterCSV.foreach(...) do |row|
    inserts.push "(row[0], row[1]...)"
  end
  User.connection.execute "INSERT INTO users (...) VALUES #{inserts.join(", ")}"
  </code></pre>
  
  <p>Everything works great. The entire process completes in (literally) seconds instead of the 1.5 hours using ActiveRecord. However, my problem lies with the boolean field. I develop locally on SQLite, but MySQL on production. When using ActiveRecord, Rails determines what to put in the "boolean" field (since almost all databases are different). I'm writing custom SQL and I want to know if there is a way I can do something like...</p>
  
  <pre><code>INSERT INTO users(..., is_active, ...) VALUES (..., ActiveRecord::Base.connection.boolean.true, ...)
  </code></pre>
  
  <p>...that correctly returns the database-specific boolean value. </p>
  
  <p>Anyone who answers "just using ActiveRecord" will be down-voted. It's simply NOT feasible in this situation. I'm also not willing to use a tinyint(1) field and use 1's or 0's. </p>
  
  <p>In summary, the value for <code>is_active</code> needs to change based on the current database connection...</p>
  
  <p>Is this even possible?</p>