Mercurial > libervia-pubsub
comparison sat_pubsub/pgsql_storage.py @ 486:39a6c0bc914b
psql: handle case when `max_items == max` on node creation
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 02 Oct 2022 15:38:42 +0200 |
parents | 97010eefdfd9 |
children |
comparison
equal
deleted
inserted
replaced
485:97010eefdfd9 | 486:39a6c0bc914b |
---|---|
279 def _createNode(self, cursor, nodeIdentifier, owner, config, schema, pep, recipient): | 279 def _createNode(self, cursor, nodeIdentifier, owner, config, schema, pep, recipient): |
280 if config['pubsub#node_type'] != 'leaf': | 280 if config['pubsub#node_type'] != 'leaf': |
281 raise error.NoCollections() | 281 raise error.NoCollections() |
282 | 282 |
283 owner = owner.userhost() | 283 owner = owner.userhost() |
284 max_items = config[const.OPT_MAX_ITEMS] | |
285 max_items = 0 if max_items == "max" else int(max_items) | |
284 | 286 |
285 try: | 287 try: |
286 cursor.execute("""INSERT INTO nodes | 288 cursor.execute("""INSERT INTO nodes |
287 (node, | 289 (node, |
288 node_type, | 290 node_type, |
302 (%s, 'leaf', %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""", | 304 (%s, 'leaf', %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""", |
303 (nodeIdentifier, | 305 (nodeIdentifier, |
304 config[const.OPT_ACCESS_MODEL], | 306 config[const.OPT_ACCESS_MODEL], |
305 config['pubsub#persist_items'], | 307 config['pubsub#persist_items'], |
306 config['pubsub#deliver_payloads'], | 308 config['pubsub#deliver_payloads'], |
307 int(config[const.OPT_MAX_ITEMS]), | 309 max_items, |
308 config[const.OPT_OVERWRITE_POLICY], | 310 config[const.OPT_OVERWRITE_POLICY], |
309 config[const.OPT_SERIAL_IDS], | 311 config[const.OPT_SERIAL_IDS], |
310 config[const.OPT_CONSISTENT_PUBLISHER], | 312 config[const.OPT_CONSISTENT_PUBLISHER], |
311 config[const.OPT_FTS_LANGUAGE], | 313 config[const.OPT_FTS_LANGUAGE], |
312 config['pubsub#send_last_published_item'], | 314 config['pubsub#send_last_published_item'], |