Skip to content

Instantly share code, notes, and snippets.

@mess110
Created December 15, 2014 23:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mess110/89f45de57fe8657da400 to your computer and use it in GitHub Desktop.
Save mess110/89f45de57fe8657da400 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# encoding: utf-8
require 'bundler'
Bundler.setup(:default)
require 'active_record'
require 'minitest/autorun'
require 'logger'
ActiveRecord::Base.establish_connection(adapter: 'postgresql', encoding: 'unicode', host: '127.17.0.3', pool: 5, username: 'postgres')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :json_models do |t|
t.json 'payload'
end unless table_exists?(:json_models)
end
class JsonModel < ActiveRecord::Base
end
class BugTest < Minitest::Test
def test_distinct_json
# this works
JsonModel.select("DISTINCT ON (json_models.id) json_models.*").to_a
# this does not
JsonModel.distinct.to_a
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment