Skip to content
Browse files

Merge pull request #20 from bryanstearns/master

Minor tweak to last-ID lookup
  • Loading branch information...
2 parents 842a11e + 8616bfb commit cd1373d8c0a89709a892db9abb2517a87646ed41 @ryanb ryanb committed Jun 29, 2011
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/populator/factory.rb
View
2 lib/populator/factory.rb
@@ -74,7 +74,7 @@ def quoted_column_names
end
def last_id_in_database
- @last_id_in_database ||= @model_class.connection.select_value("SELECT #{@model_class.primary_key} FROM #{@model_class.quoted_table_name} ORDER BY #{@model_class.primary_key} DESC", "#{@model_class.name} Last ID").to_i
+ @last_id_in_database ||= @model_class.connection.select_value("SELECT MAX(#{@model_class.primary_key}) FROM #{@model_class.quoted_table_name}", "#{@model_class.name} Last ID").to_i
end
def columns_sql

0 comments on commit cd1373d

Please sign in to comment.
Something went wrong with that request. Please try again.