Skip to content

Commit

Permalink
Errors mapping updated to PostgreSQL 13
Browse files Browse the repository at this point in the history
  • Loading branch information
dvarrazzo committed Sep 5, 2020
1 parent c203d68 commit dd1724c
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ What's new in psycopg 2.8.6
(:ticket:`#1101`).
- Fixed search of mxDateTime headers in virtualenvs (:ticket:`#996`).
- Added missing values from errorcodes (:ticket:`#1133`).
- `~psycopg2.errorcodes` map and `~psycopg2.errors` classes updated to
PostgreSQL 13.
- Wheel package compiled against OpenSSL 1.1.1g.


Expand Down
2 changes: 1 addition & 1 deletion doc/src/errorcodes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ An example of the available constants defined in the module:
'42P01'

Constants representing all the error values defined by PostgreSQL versions
between 8.1 and 12 are included in the module.
between 8.1 and 13 are included in the module.


.. autofunction:: lookup(code)
Expand Down
4 changes: 3 additions & 1 deletion doc/src/errors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@

.. versionchanged:: 2.8.4 added errors introduced in PostgreSQL 12

.. versionchanged:: 2.8.6 added errors introduced in PostgreSQL 13

This module exposes the classes psycopg raises upon receiving an error from
the database with a :sql:`SQLSTATE` value attached (available in the
`~psycopg2.Error.pgcode` attribute). The content of the module is generated
from the PostgreSQL source code and includes classes for every error defined
by PostgreSQL in versions between 9.1 and 12.
by PostgreSQL in versions between 9.1 and 13.

Every class in the module is named after what referred as "condition name" `in
the documentation`__, converted to CamelCase: e.g. the error 22012,
Expand Down
1 change: 1 addition & 0 deletions lib/errorcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def lookup(code, _cache={}):
INVALID_TABLESAMPLE_REPEAT = '2202G'
INVALID_TABLESAMPLE_ARGUMENT = '2202H'
DUPLICATE_JSON_OBJECT_KEY_VALUE = '22030'
INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION = '22031'
INVALID_JSON_TEXT = '22032'
INVALID_SQL_JSON_SUBSCRIPT = '22033'
MORE_THAN_ONE_SQL_JSON_ITEM = '22034'
Expand Down
1 change: 1 addition & 0 deletions psycopg/sqlstate_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
{"2202G", "InvalidTablesampleRepeat"},
{"2202H", "InvalidTablesampleArgument"},
{"22030", "DuplicateJsonObjectKeyValue"},
{"22031", "InvalidArgumentForSqlJsonDatetimeFunction"},
{"22032", "InvalidJsonText"},
{"22033", "InvalidSqlJsonSubscript"},
{"22034", "MoreThanOneSqlJsonItem"},
Expand Down
2 changes: 1 addition & 1 deletion scripts/make_errorcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def main():
file_start = read_base_file(filename)
# If you add a version to the list fix the docs (in errorcodes.rst)
classes, errors = fetch_errors(
['9.1', '9.2', '9.3', '9.4', '9.5', '9.6', '10', '11', '12'])
['9.1', '9.2', '9.3', '9.4', '9.5', '9.6', '10', '11', '12', '13'])

disambiguate(errors)

Expand Down
2 changes: 1 addition & 1 deletion scripts/make_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def main():

# If you add a version to the list fix the docs (in errors.rst)
classes, errors = fetch_errors(
['9.1', '9.2', '9.3', '9.4', '9.5', '9.6', '10', '11', '12'])
['9.1', '9.2', '9.3', '9.4', '9.5', '9.6', '10', '11', '12', '13'])

f = open(filename, "w")
print("/*\n * Autogenerated by 'scripts/make_errors.py'.\n */\n", file=f)
Expand Down

0 comments on commit dd1724c

Please sign in to comment.