Mercurial > p > roundup > code
comparison roundup/backends/back_postgresql.py @ 8302:82a26ea1afdf
issue2551376: Fix tracebacks in item templates
| author | Ralf Schlatterbeck <rsc@runtux.com> |
|---|---|
| date | Wed, 26 Feb 2025 11:24:13 +0100 |
| parents | cfa7d43a3658 |
| children | 45ec660eb7f7 |
comparison
equal
deleted
inserted
replaced
| 8301:3ba8078843db | 8302:82a26ea1afdf |
|---|---|
| 114 # FATAL: database "rounduptest" does not exist\n' | 114 # FATAL: database "rounduptest" does not exist\n' |
| 115 # ugh. | 115 # ugh. |
| 116 # | 116 # |
| 117 # Database name is any character sequence not including a " or | 117 # Database name is any character sequence not including a " or |
| 118 # whitespace. Arguably both are allowed by: | 118 # whitespace. Arguably both are allowed by: |
| 119 # | 119 # |
| 120 # https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS | 120 # https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS |
| 121 # | 121 # |
| 122 # with suitable quoting but ... really. | 122 # with suitable quoting but ... really. |
| 123 search = re.search( | 123 search = re.search( |
| 124 r'FATAL:\s+database\s+"([^"\s]*)"\s+does\s+not\s+exist', | 124 r'FATAL:\s+database\s+"([^"\s]*)"\s+does\s+not\s+exist', |
| 168 # FATAL: database "rounduptest" does not exist\n' | 168 # FATAL: database "rounduptest" does not exist\n' |
| 169 # ugh. | 169 # ugh. |
| 170 # | 170 # |
| 171 # Database name is any character sequence not including a " or | 171 # Database name is any character sequence not including a " or |
| 172 # whitespace. Arguably both are allowed by: | 172 # whitespace. Arguably both are allowed by: |
| 173 # | 173 # |
| 174 # https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS | 174 # https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS |
| 175 # | 175 # |
| 176 # with suitable quoting but ... really. | 176 # with suitable quoting but ... really. |
| 177 search = re.search( | 177 search = re.search( |
| 178 r'FATAL:\s+database\s+"([^"\s]*)"\s+does\s+not\s+exist', | 178 r'FATAL:\s+database\s+"([^"\s]*)"\s+does\s+not\s+exist', |
| 558 # reset the sequences | 558 # reset the sequences |
| 559 for cn in self.classes: | 559 for cn in self.classes: |
| 560 self.cursor.execute('DROP SEQUENCE _%s_ids' % cn) | 560 self.cursor.execute('DROP SEQUENCE _%s_ids' % cn) |
| 561 self.cursor.execute('CREATE SEQUENCE _%s_ids' % cn) | 561 self.cursor.execute('CREATE SEQUENCE _%s_ids' % cn) |
| 562 | 562 |
| 563 def getnode (self, classname, nodeid, fetch_multilinks=True): | |
| 564 """ For use of savepoint see 'Class' below """ | |
| 565 self.sql('savepoint sp') | |
| 566 try: | |
| 567 getnode = rdbms_common.Database.getnode | |
| 568 return getnode(self, classname, nodeid, fetch_multilinks) | |
| 569 except psycopg2.errors.DataError as err: | |
| 570 self.sql('rollback to savepoint sp') | |
| 571 raise hyperdb.HyperdbValueError(str (err).split('\n')[0]) | |
| 572 | |
| 563 | 573 |
| 564 class PostgresqlClass: | 574 class PostgresqlClass: |
| 565 order_by_null_values = '(%s is not NULL)' | 575 order_by_null_values = '(%s is not NULL)' |
| 566 case_insensitive_like = 'ILIKE' | 576 case_insensitive_like = 'ILIKE' |
| 567 | 577 |
| 568 | 578 |
| 569 class Class(PostgresqlClass, rdbms_common.Class): | 579 class Class(PostgresqlClass, rdbms_common.Class): |
| 570 pass | 580 """ We re-raise database-specific data errors as HyperdbValueError |
| 581 Note that we re-use the savepoint so that at most one savepoint | |
| 582 is used. | |
| 583 """ | |
| 584 | |
| 585 def filter(self, *args, **kw): | |
| 586 self.db.sql('savepoint sp') | |
| 587 try: | |
| 588 return rdbms_common.Class.filter(self, *args, **kw) | |
| 589 except psycopg2.errors.DataError as err: | |
| 590 self.db.sql('rollback to savepoint sp') | |
| 591 raise hyperdb.HyperdbValueError(str (err).split('\n')[0]) | |
| 592 | |
| 593 def filter_iter(self, *args, **kw): | |
| 594 self.db.sql('savepoint sp') | |
| 595 try: | |
| 596 return rdbms_common.Class.filter_iter(self, *args, **kw) | |
| 597 except psycopg2.errors.DataError as err: | |
| 598 self.db.sql('rollback to savepoint sp') | |
| 599 raise hyperdb.HyperdbValueError(str (err).split('\n')[0]) | |
| 600 | |
| 601 def is_retired(self, nodeid): | |
| 602 self.db.sql('savepoint sp') | |
| 603 try: | |
| 604 return rdbms_common.Class.is_retired(self, nodeid) | |
| 605 except psycopg2.errors.DataError as err: | |
| 606 self.db.sql('rollback to savepoint sp') | |
| 607 raise hyperdb.HyperdbValueError (str (err).split('\n')[0]) | |
| 571 | 608 |
| 572 | 609 |
| 573 class IssueClass(PostgresqlClass, rdbms_common.IssueClass): | 610 class IssueClass(PostgresqlClass, rdbms_common.IssueClass): |
| 574 pass | 611 pass |
| 575 | 612 |
