Mercurial > libervia-pubsub
comparison sat_pubsub/pgsql_storage.py @ 247:70fae534b83a
fixed getItems select in pgsql_storage
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 31 May 2012 00:24:20 +0200 |
parents | e11e99246be5 |
children | 50f6ee966da8 |
comparison
equal
deleted
inserted
replaced
246:2a948abb77ed | 247:70fae534b83a |
---|---|
597 | 597 |
598 | 598 |
599 def _getItems(self, cursor, maxItems): | 599 def _getItems(self, cursor, maxItems): |
600 self._checkNodeExists(cursor) | 600 self._checkNodeExists(cursor) |
601 query = """SELECT data FROM nodes | 601 query = """SELECT data FROM nodes |
602 NATURAL JOIN items | 602 INNER JOIN items USING (node_id) |
603 WHERE node=%s ORDER BY date DESC""" | 603 WHERE node=%s ORDER BY date DESC""" |
604 if maxItems: | 604 if maxItems: |
605 cursor.execute(query + " LIMIT %s", | 605 cursor.execute(query + " LIMIT %s", |
606 (self.nodeIdentifier, | 606 (self.nodeIdentifier, |
607 maxItems)) | 607 maxItems)) |
620 def _getItemsById(self, cursor, itemIdentifiers): | 620 def _getItemsById(self, cursor, itemIdentifiers): |
621 self._checkNodeExists(cursor) | 621 self._checkNodeExists(cursor) |
622 items = [] | 622 items = [] |
623 for itemIdentifier in itemIdentifiers: | 623 for itemIdentifier in itemIdentifiers: |
624 cursor.execute("""SELECT data FROM nodes | 624 cursor.execute("""SELECT data FROM nodes |
625 NATURAL JOIN items | 625 INNER JOIN items USING (node_id) |
626 WHERE node=%s AND item=%s""", | 626 WHERE node=%s AND item=%s""", |
627 (self.nodeIdentifier, | 627 (self.nodeIdentifier, |
628 itemIdentifier)) | 628 itemIdentifier)) |
629 result = cursor.fetchone() | 629 result = cursor.fetchone() |
630 if result: | 630 if result: |