Skip to content

Instantly share code, notes, and snippets.

@kuldeepaggarwal
Last active December 31, 2015 18:29
Show Gist options
  • Select an option

  • Save kuldeepaggarwal/8026843 to your computer and use it in GitHub Desktop.

Select an option

Save kuldeepaggarwal/8026843 to your computer and use it in GitHub Desktop.
Rails Issue#13378
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'pg'
GEMFILE
system 'bundle'
end
require 'bundler'
Bundler.setup(:default)
require 'active_record'
require 'minitest/autorun'
require 'logger'
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(
adapter: 'postgresql',
encoding: 'utf8',
database: 'kd_test',
username: 'postgres',
password: '',
host: 'localhost'
)
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :articles, force: true do |t|
t.integer :number
end
end
class Article < ActiveRecord::Base
end
class BugTest < Minitest::Test
def test_multiline_insert_sql
connection = ActiveRecord::Base.connection
id = connection.insert_sql(<<-SQL)
insert into articles(
number)
values(
5152
)
SQL
expect = connection.query('select max(id) from articles').first.first
assert_equal expect, id
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment