Skip to content

Instantly share code, notes, and snippets.

@senny
Created February 3, 2014 16:12
Show Gist options
  • Save senny/8786850 to your computer and use it in GitHub Desktop.
Save senny/8786850 to your computer and use it in GitHub Desktop.
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: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :posts do |t|
t.string :key
end
end
class Post < ActiveRecord::Base
end
class BugTest < Minitest::Test
def test_order_by_key
Post.create(key: "b")
Post.create(key: "c")
Post.create(key: "a")
assert_equal ["a", "b", "c"], Post.order(:key).to_a.map(&:key)
end
end
@senny
Copy link
Author

senny commented Feb 3, 2014

-- create_table(:posts)
D, [2014-02-03T17:03:29.502975 #43608] DEBUG -- :    (0.7ms)  CREATE TABLE "posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "key" varchar(255))
   -> 0.0063s
Run options: --seed 13107

# Running:

D, [2014-02-03T17:03:29.545909 #43608] DEBUG -- :    (0.1ms)  begin transaction
D, [2014-02-03T17:03:29.548277 #43608] DEBUG -- :   SQL (0.1ms)  INSERT INTO "posts" ("key") VALUES (?)  [["key", "b"]]
D, [2014-02-03T17:03:29.548565 #43608] DEBUG -- :    (0.1ms)  commit transaction
D, [2014-02-03T17:03:29.548904 #43608] DEBUG -- :    (0.0ms)  begin transaction
D, [2014-02-03T17:03:29.549347 #43608] DEBUG -- :   SQL (0.1ms)  INSERT INTO "posts" ("key") VALUES (?)  [["key", "c"]]
D, [2014-02-03T17:03:29.549521 #43608] DEBUG -- :    (0.0ms)  commit transaction
D, [2014-02-03T17:03:29.549726 #43608] DEBUG -- :    (0.0ms)  begin transaction
D, [2014-02-03T17:03:29.550040 #43608] DEBUG -- :   SQL (0.0ms)  INSERT INTO "posts" ("key") VALUES (?)  [["key", "a"]]
D, [2014-02-03T17:03:29.550206 #43608] DEBUG -- :    (0.0ms)  commit transaction
D, [2014-02-03T17:03:29.550646 #43608] DEBUG -- :   Post Load (0.1ms)  SELECT "posts".* FROM "posts"   ORDER BY "posts"."key" ASC
.

Finished in 0.012822s, 77.9910 runs/s, 77.9910 assertions/s.

1 runs, 1 assertions, 0 failures, 0 errors, 0 skips

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment