Skip to content

Commit

Permalink
Support smallserial on PostgreSQL primary keys
Browse files Browse the repository at this point in the history
  • Loading branch information
j-a-m-l committed May 24, 2020
1 parent 5d056c3 commit 5144292
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/sequel/adapters/shared/postgres.rb
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ def column_definition_collate_sql(sql, column)
# default value is given.
def column_definition_default_sql(sql, column)
super
if !column[:serial] && !['serial', 'bigserial'].include?(column[:type].to_s) && !column[:default]
if !column[:serial] && !['smallserial', 'serial', 'bigserial'].include?(column[:type].to_s) && !column[:default]
if (identity = column[:identity])
sql << " GENERATED "
sql << (identity == :always ? "ALWAYS" : "BY DEFAULT")
Expand Down
4 changes: 2 additions & 2 deletions spec/adapters/postgres_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@
end
end if DB.server_version >= 90000

it "should support primary_key with :type=>:serial or :type=>:bigserial" do
[:serial, :bigserial, 'serial', 'bigserial'].each do |type|
it "should support primary_key with :type=>:smallserial, :type=>:serial or :type=>:bigserial" do
[:smallserial, :serial, :bigserial, 'smallserial', 'serial', 'bigserial'].each do |type|
@db.create_table!(:tmp_dolls){primary_key :id, :type=>type}
@db[:tmp_dolls].insert
@db[:tmp_dolls].get(:id).must_equal 1
Expand Down

0 comments on commit 5144292

Please sign in to comment.