taoensso / faraday

Amazon DynamoDB client for Clojure
https://www.taoensso.com/faraday
Eclipse Public License 1.0
238 stars 84 forks source link

put-item :expected not working as documented #65

Closed skbach closed 9 years ago

skbach commented 9 years ago

(far/create-table client-opts "test" [:id :s])

(far/query client-opts "test" {:id [:eq "x"]})

[] ;; no records exist

(far/put-item client-opts "test" {:id "x"} {:expected {:id false}})

ConditionalCheckFailedException

I assumed the first time, the put should succeed, and the second time it should throw. The docs says to provide {:attr false} to ensure it doesn't already exist, but this results in it always failing, even the first time.

Thanks.

ptaoussanis commented 9 years ago

I'm guessing that this is a [docstring?] bug caused by https://github.com/ptaoussanis/faraday/commit/c8919eb60d1dc59b12db307fcbda2d32c0f3b1eb

Could you try again with {:expected :not-exists} and let me know if that works? Thanks!

skbach commented 9 years ago

Ya, {:expected {:id :not-exists}} works as expected.

Is there somewhere I could've gleaned that from the docs/source myself? I'm not sure how the commit you mentioned broke that.

Thanks.

tcoupland commented 9 years ago

Hi,

This was introduced by me in: https://github.com/ptaoussanis/faraday/commit/c1ec999834b4218512b81e50d8645cec10e9f10c

Would have sworn i'd changed the doc string to match, but apparently not. Sorry about that.

ptaoussanis commented 9 years ago

Okay, closing this.

Thanks for the fix @mantree, much appreciated! For future commits, could I ask that you please always rebase on the latest master/dev branch to make sure you've got the latest code state? Was a minor doc-string clash in this case, but wouldn't want to risk you needlessly spending time on merge conflicts, etc.

Cheers! :-)