Skip to content

Instantly share code, notes, and snippets.

@phoet phoet/example.rb
Last active Jul 29, 2019

Embed
What would you like to do?
group by with first
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
gem "rails", '6.0.0.rc2'
# gem "rails", '6.0.0.rc1'
# gem "rails", '6.0.0.beta1'
# gem "rails", '5.2.3'
gem 'pg'
end
require 'pg'
require "active_record"
require 'active_support'
require "minitest/autorun"
require "logger"
ActiveRecord::Base.establish_connection(adapter: "postgresql", database: "penseo_test2")
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :posts, force: true do |t|
t.timestamps(null: false)
end
end
class Post < ActiveRecord::Base
end
class BugTest < Minitest::Test
def test_fails_with_distinct_size
post = Post.create!
expected = post.created_at
assert_equal expected, Post.select('min(created_at) as min').reorder('').to_a.first.min
assert_equal expected, Post.select('min(created_at) as min').reorder('').first.min
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.