Last active
December 31, 2015 18:29
-
-
Save kuldeepaggarwal/8026843 to your computer and use it in GitHub Desktop.
Revisions
-
kuldeepaggarwal revised this gist
Dec 18, 2013 . 1 changed file with 28 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -51,3 +51,31 @@ def test_multiline_insert_sql end end Output: -- create_table(:articles, {:force=>true}) D, [2013-12-19T00:45:25.744734 #81931] DEBUG -- : (9.3ms) DROP TABLE "articles" D, [2013-12-19T00:45:25.749148 #81931] DEBUG -- : (4.1ms) CREATE TABLE "articles" ("id" serial primary key, "number" integer) -> 0.0487s Run options: --seed 19220 # Running: D, [2013-12-19T00:45:25.767565 #81931] DEBUG -- : (1.2ms) insert into articles( number) values( 5152 ) D, [2013-12-19T00:45:25.768431 #81931] DEBUG -- : (0.7ms) select max(id) from articles F Finished in 0.008476s, 117.9802 runs/s, 117.9802 assertions/s. 1) Failure: BugTest#test_multiline_insert_sql [has_one_and_has_many.rb:50]: Expected: "1" Actual: nil 1 runs, 1 assertions, 1 failures, 0 errors, 0 skips -
kuldeepaggarwal revised this gist
Dec 18, 2013 . No changes.There are no files selected for viewing
-
kuldeepaggarwal created this gist
Dec 18, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,53 @@ 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