RqlCompileError: Unrecognized optional argument `upsert`
Hey guys,
I started playing with RethinkDB today. Everything worked well until I started using ORM.
import rethinkdb as r
from rethinkORM import RethinkModel
r.connect( "localhost", 28015).repl()
class test(RethinkModel):
table = "authors"
dhdProp = test(what="DHD", planet="P3X-439", description="Dial HomeDevice")
dhdProp.id="DHD_P3X_439"
dhdProp.save()
the result is
rethinkdb.errors.RqlCompileError: RqlCompileError: Unrecognized optional argument `upsert`. in:
r.table('authors').insert(r.expr({'planet': 'P3X-439', 'what': 'DHD', 'description': 'Dial HomeDevice', 'id': 'DHD_P3X_439'}), durability='soft', upsert=True)
Any idea what to do?
Looks like the python driver was updated to replace upsert=True with conflict='replace' in 1.14. The requirements do specify 1.7, but it should probably be updated in line in both master and dev.
The change is simple for master (see below), I'll look at making sure it doesn't break tests and submit a PR as soon as I get a chance.
Reference: https://github.com/rethinkdb/rethinkdb/issues/1838
diff --git a/rethinkORM/rethinkModel.py b/rethinkORM/rethinkModel.py
index e39fb96..a4b2980 100644
--- a/rethinkORM/rethinkModel.py
+++ b/rethinkORM/rethinkModel.py
@@ -33,7 +33,7 @@ class RethinkModel(object):
non_atomic = False
"""Determins if the transaction can be non atomic or not"""
- upsert = True
+ conflict = 'replace'
"""Will either update, or create a new object if true and a primary key is
given."""
@@ -261,7 +261,7 @@ name exists in data""")
reply = r.table(self.table) \
.insert(self._data,
durability=self.durability,
- upsert=self.upsert) \
+ conflict=self.conflict) \
.run(self._conn)
self._new = False
Thanks for looking into this so fast, @grieve. I don't believe I have any tests that are using or testing upsert (although I probably should) so just that change should be fine.