Skip to content

Commit

Permalink
Merge pull request ryanb#20 from bryanstearns/master
Browse files Browse the repository at this point in the history
Minor tweak to last-ID lookup
  • Loading branch information
ryanb committed Jun 29, 2011
2 parents 842a11e + 8616bfb commit cd1373d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/populator/factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cd1373d

Please sign in to comment.