Skip to content

Commit bc55874

Browse files
satyanashdr-itz
authored andcommitted
add failing test for postgresql when primary key is not the first column when insert_returning
1 parent 5bd5d70 commit bc55874

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
require 'test_helper'
2+
require 'db/postgres'
3+
4+
class PrimaryKeyIsNotTheFirstColumnTest < Test::Unit::TestCase
5+
6+
class CreateEmployees < ActiveRecord::Migration[4.2]
7+
def self.up
8+
create_table 'employees', :id => false do |t|
9+
t.string :full_name, :null => false
10+
t.primary_key :id, :serial
11+
end
12+
end
13+
def self.down
14+
drop_table 'employees'
15+
end
16+
end
17+
18+
def setup
19+
CreateEmployees.up
20+
end
21+
22+
def teardown
23+
CreateEmployees.down
24+
end
25+
26+
class Employee < ActiveRecord::Base
27+
end
28+
29+
def test_returning_when_primary_key_is_not_the_first_column
30+
e = Employee.new
31+
e.full_name = 'Slartibartfast'
32+
e.save!
33+
e.reload
34+
assert_equal 1, e.id
35+
end
36+
37+
end

0 commit comments

Comments
 (0)