README.md in upsert-0.3.0 vs README.md in upsert-0.3.1
- old
+ new
@@ -31,12 +31,18 @@
require 'upsert/active_record_upsert'
Pet.upsert({:name => 'Jerry'}, :breed => 'beagle')
Pet.upsert({:name => 'Pierre'}, :breed => 'tabby')
-### The "fixed column set" gotcha
+### Gotchas
+#### Undefined behavior if you use this without properly defining UNIQUE indexes
+
+Make sure you're upserting against either primary key columns or columns with UNIQUE indexes or both.
+
+#### Columns are set based on the first row you pass
+
Currently, the first row you pass in determines the columns that will be used. That's useful for mass importing of many rows with the same columns, but is surprising if you're trying to use a single `Upsert` object to add arbitrary data. For example, this won't work:
Upsert.batch(Pet.connection, Pet.table_name) do |upsert|
upsert.row({:name => 'Jerry'}, :breed => 'beagle')
upsert.row({:tag_number => 456}, :spiel => 'great cat') # won't work - doesn't use same columns
@@ -50,9 +56,10 @@
## Wishlist
Pull requests for any of these would be greatly appreciated:
1. Fix SQLite tests.
+2. Provide `require 'upsert/debug'` that will make sure you are selecting on columns that have unique indexes
2. If you think there's a fix for the "fixed column set" gotcha...
3. Naming suggestions: should "document" be called "setters" or "attributes"?
## Real-world usage