From 904e464dfabadf3cf37cef68fa671819ecd9eab2 Mon Sep 17 00:00:00 2001 From: Brian Abelson Date: Sat, 10 Aug 2013 21:34:00 -0400 Subject: [PATCH] allow keys arg for upsert to be a string I want to be able to use `upsert` without formatting the keys arg as a list, ie: ``` table.upsert(new_data, "id") ``` --- dataset/persistence/table.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dataset/persistence/table.py b/dataset/persistence/table.py index 0158930..fd41918 100644 --- a/dataset/persistence/table.py +++ b/dataset/persistence/table.py @@ -147,6 +147,10 @@ class Table(object): data = dict(id=10, title='I am a banana!') table.upsert(data, ['id']) """ + # check whether keys arg is a string and format as a list + if isinstance(keys, basestring): + keys = [keys] + self._check_dropped() if ensure: self.create_index(keys)