diff --git a/lib/closure_tree/numeric_order_support.rb b/lib/closure_tree/numeric_order_support.rb index db214384..46909670 100644 --- a/lib/closure_tree/numeric_order_support.rb +++ b/lib/closure_tree/numeric_order_support.rb @@ -44,7 +44,8 @@ def reorder_with_parent_id(parent_id, minimum_sort_order_value = nil) FROM #{quoted_table_name} WHERE #{where_eq(parent_column_name, parent_id)} #{min_where} ) AS t - WHERE #{quoted_table_name}.#{quoted_id_column_name} = t.id + WHERE #{quoted_table_name}.#{quoted_id_column_name} = t.id and + #{quoted_table_name}.#{quoted_order_column(false)} is distinct from t.seq + #{minimum_sort_order_value.to_i - 1} SQL end