From 0ad8e469725478d6a8c8c3310523db95b188a7f0 Mon Sep 17 00:00:00 2001 From: Mike Naberezny Date: Mon, 15 Jan 2018 10:05:43 -0800 Subject: [PATCH] Restore support for PostgreSQL with Rails versions before 5.0.0 --- CHANGELOG.md | 7 +++++++ lib/seed-fu/seeder.rb | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index baf714c..42b4a4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +Version 2.3.8 +------------- + +Bug fixes: + +* Restored support for PostgreSQL with Rails versions before 5.0.0 broken in Seed Fu 2.3.7. + Version 2.3.7 ------------- diff --git a/lib/seed-fu/seeder.rb b/lib/seed-fu/seeder.rb index def2a43..3a48393 100644 --- a/lib/seed-fu/seeder.rb +++ b/lib/seed-fu/seeder.rb @@ -91,7 +91,8 @@ def update_id_sequence quoted_id = @model_class.connection.quote_column_name(@model_class.primary_key) sequence = @model_class.sequence_name - if @model_class.connection.postgresql_version >= 100000 + # TODO postgresql_version was made public in Rails 5.0.0, remove #send when support for earlier versions are dropped + if @model_class.connection.send(:postgresql_version) >= 100000 sql =<<-EOS SELECT setval('#{sequence}', (SELECT GREATEST(MAX(#{quoted_id})+(SELECT seqincrement FROM pg_sequence WHERE seqrelid = '#{sequence}'::regclass), (SELECT seqmin FROM pg_sequence WHERE seqrelid = '#{sequence}'::regclass)) FROM #{@model_class.quoted_table_name}), false) EOS