Closed 34code closed 2 years ago
I've found an alternative way to accomplish this.
i.prices.where(price_id: "eCampus.com_used").first.update(amount: 2200)
when record exists and Price.create()....
when a record does not exist.
Would have really liked to use upsert though
Coming back on this after having faced the same issue (with kaminari in my case, not upset
), I found out that the problem come from the order_by
. Using without_ordering
avoided that error.
In your case Price.without_ordering.upsert(...)
may work, I haven't tested it.
Anyway, the issue is not related to the NoBrainer ORM, nor to the RethinkDB driver, but the RethinkDB database itself so I close this issue. Feel free to update this issue to tell if my solution works for you.
I'm trying the following in my app..
p_ecamp_u = Price.upsert(source: "eCampus.com", condition: "used", amount: 2400, buy_link: "http://www.shareasale.com/r.cfm?u=728790&b=289670&m=13375&afftrack=&urllink=www.ecampus.com/bk_detail.asp?isbn=9780815700258", updated_at: Time.now, item: i, price_id: "eCampus.com_used")
but it gives me the following error:
I have checked that the index
price_id
exists as a secondary index. What am I doing wrong here? I hope this is an error on my part and not nobrainer not supporting upserts on large (20M docs) tables