Mercurial > libervia-pubsub
comparison sat_pubsub/pgsql_storage.py @ 324:e73e42b4f6ff
pgsql storage: getItemsIndex raise NodeNotFound in this make sense
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 08 Jan 2016 17:27:44 +0100 |
parents | 8496af26be45 |
children | 82d1259b3e36 |
comparison
equal
deleted
inserted
replaced
323:8496af26be45 | 324:e73e42b4f6ff |
---|---|
920 query_select = "SELECT row_number from (SELECT row_number() OVER ({}), item".format(query_order) | 920 query_select = "SELECT row_number from (SELECT row_number() OVER ({}), item".format(query_order) |
921 query.insert(0, query_select) | 921 query.insert(0, query_select) |
922 query.append(") as x WHERE item=%s") | 922 query.append(") as x WHERE item=%s") |
923 args.append(item_id) | 923 args.append(item_id) |
924 | 924 |
925 | |
926 cursor.execute(' '.join(query), args) | 925 cursor.execute(' '.join(query), args) |
927 # XXX: row_number start at 1, but we want that index start at 0 | 926 # XXX: row_number start at 1, but we want that index start at 0 |
928 return cursor.fetchall()[0][0] - 1 | 927 try: |
928 return cursor.fetchall()[0][0] - 1 | |
929 except IndexError: | |
930 raise error.NodeNotFound() | |
929 | 931 |
930 def getItemsPublishers(self, itemIdentifiers): | 932 def getItemsPublishers(self, itemIdentifiers): |
931 """Get the publishers for all given identifiers | 933 """Get the publishers for all given identifiers |
932 | 934 |
933 @return (dict[unicode, jid.JID]): map of itemIdentifiers to publisher | 935 @return (dict[unicode, jid.JID]): map of itemIdentifiers to publisher |