]> git.ipfire.org Git - thirdparty/psycopg.git/log
thirdparty/psycopg.git
23 months agodocs: improve docs about raw query cursors, add release note 560/head
Daniele Varrazzo [Tue, 15 Aug 2023 15:28:01 +0000 (16:28 +0100)] 
docs: improve docs about raw query cursors, add release note

23 months agotests: fix cursor tests to run on raw cursors too
Daniele Varrazzo [Mon, 14 Aug 2023 18:34:19 +0000 (19:34 +0100)] 
tests: fix cursor tests to run on raw cursors too

23 months agofix: fix TypeInfo.fetch() with connections using RawCursor as factory
Daniele Varrazzo [Sun, 13 Aug 2023 09:48:26 +0000 (10:48 +0100)] 
fix: fix TypeInfo.fetch() with connections using RawCursor as factory

23 months agorefactor: make is_param_sequence a type guard
Daniele Varrazzo [Sun, 13 Aug 2023 09:43:43 +0000 (10:43 +0100)] 
refactor: make is_param_sequence a type guard

Reduce the need of typing hints here and there, although, if it returns
false, it doesn't guarantee "the other half of the union".

23 months agoAdd raw query support with PostgreSQL native placeholders
Joel Jakobsson [Tue, 9 May 2023 00:49:03 +0000 (02:49 +0200)] 
Add raw query support with PostgreSQL native placeholders

This commit introduces support for raw queries with PostgreSQL's native
placeholders ($1, $2, etc.) in psycopg3. By setting the use_raw_query attribute
to True in a custom cursor class, users can enable the use of raw queries with
native placeholders.

The code demonstrates how to create a custom RawQueryCursor class that sets the
use_raw_query attribute to True. This custom cursor class can be set as the
cursor_factory when connecting to the database, allowing users to choose between
PostgreSQL's native placeholders or the standard %s placeholder in their queries.
The code also demonstrates how both styles of placeholders can coexist. Test
cases are included to verify the correct behavior of the new feature.

23 months agoMerge branch 'tests-refactoring'
Daniele Varrazzo [Tue, 15 Aug 2023 14:53:00 +0000 (15:53 +0100)] 
Merge branch 'tests-refactoring'

23 months agotest(crdb): accept different exception on multi-query prepare attempt
Daniele Varrazzo [Sat, 5 Aug 2023 19:53:35 +0000 (20:53 +0100)] 
test(crdb): accept different exception on multi-query prepare attempt

23 months agotest: unify server and client async cursor tests
Daniele Varrazzo [Sat, 5 Aug 2023 18:38:31 +0000 (19:38 +0100)] 
test: unify server and client async cursor tests

Also clean up differences between sync and async cursor tests.

23 months agotest: refactor common cursor tests using parametric fixture
Daniele Varrazzo [Mon, 15 May 2023 09:18:28 +0000 (11:18 +0200)] 
test: refactor common cursor tests using parametric fixture

Tests common to Cursor and BaseCursor now use the same code, with a
parametric connection fixture to run both them.

Tests specific to one of the class moved to a module of their own.

TODO: copy tests might do the same. Async cursors tests should be
refactored too.

23 months agofix: rename QueuedLibpqWriter object
Daniele Varrazzo [Thu, 10 Aug 2023 00:37:22 +0000 (01:37 +0100)] 
fix: rename QueuedLibpqWriter object

It was mistakenly named Driver, not Writer.

23 months agofix: fix infinite loop and OOM in bad executemany
Daniele Varrazzo [Sat, 5 Aug 2023 21:15:05 +0000 (22:15 +0100)] 
fix: fix infinite loop and OOM in bad executemany

The bad condition is only reached using COPY into executemany in
pipeline mode and with prepared statements disabled. It should probably
never happen outside the unit test.

23 months agoMerge branch 'numpy-types-support'
Daniele Varrazzo [Sat, 5 Aug 2023 14:21:46 +0000 (15:21 +0100)] 
Merge branch 'numpy-types-support'

23 months agofeat(crdb): add numpy support 332/head
Daniele Varrazzo [Thu, 3 Aug 2023 13:02:23 +0000 (14:02 +0100)] 
feat(crdb): add numpy support

23 months agofix(c): don't try to mutate Cython type
Daniele Varrazzo [Wed, 2 Aug 2023 00:14:04 +0000 (01:14 +0100)] 
fix(c): don't try to mutate Cython type

These types are now marked immutable. Use a module variable instead.

23 months agofix(copy): fix dumping by oid in text mode
Daniele Varrazzo [Fri, 13 Jan 2023 01:30:05 +0000 (01:30 +0000)] 
fix(copy): fix dumping by oid in text mode

It is less useful than in binary mode, but it was being pretty much
ignored.

23 months agofix(numpy): fix dumping numpy values by oid
Daniele Varrazzo [Fri, 13 Jan 2023 01:24:45 +0000 (01:24 +0000)] 
fix(numpy): fix dumping numpy values by oid

23 months agorefactor(numpy): get OIDs from the _oid module
Daniele Varrazzo [Mon, 9 Jan 2023 10:35:20 +0000 (10:35 +0000)] 
refactor(numpy): get  OIDs from the _oid module

Also drop context optionality in adapters registration.

23 months agodocs: add news entry and docs about numpy scalars support
Daniele Varrazzo [Mon, 9 Jan 2023 08:30:41 +0000 (08:30 +0000)] 
docs: add news entry and docs about numpy scalars support

23 months agofeat: add C numpy dumpers
Daniele Varrazzo [Fri, 6 Jan 2023 19:04:53 +0000 (19:04 +0000)] 
feat: add C numpy dumpers

23 months agodocs: improve comment about why we need to register builtin numerics last
Daniele Varrazzo [Fri, 6 Jan 2023 19:04:19 +0000 (19:04 +0000)] 
docs: improve comment about why we need to register builtin numerics last

23 months agorefactor(c): add _IntOrSubclass dumper to the C dumpers too
Daniele Varrazzo [Fri, 6 Jan 2023 18:28:23 +0000 (18:28 +0000)] 
refactor(c): add _IntOrSubclass dumper to the C dumpers too

23 months agotest(numpy) avoid overflow testing with int16
Daniele Varrazzo [Mon, 19 Dec 2022 15:16:40 +0000 (15:16 +0000)] 
test(numpy) avoid overflow testing with int16

23 months agotest(numpy): drop test with deprecated alias
Daniele Varrazzo [Mon, 19 Dec 2022 15:04:48 +0000 (15:04 +0000)] 
test(numpy): drop test with deprecated alias

23 months agotest(numpy): add dump tests with list of numpy values
Daniele Varrazzo [Mon, 19 Dec 2022 15:01:39 +0000 (15:01 +0000)] 
test(numpy): add dump tests with list of numpy values

23 months agotest(numpy): allow more approximation comparing float16 values
Daniele Varrazzo [Sat, 17 Dec 2022 04:08:56 +0000 (04:08 +0000)] 
test(numpy): allow more approximation comparing float16 values

    >>> numpy.float16("-0.00018227100372314453")
    -0.0001823

    >>> -0.0001823 == pytest.approx(-0.00018227100372314453, rel=1e-5)
    False

    >>> -0.0001823 == pytest.approx(-0.00018227100372314453, rel=1e-3)
    True

23 months agofix(numpy): fix dumpers registration order
Daniele Varrazzo [Sat, 17 Dec 2022 03:47:18 +0000 (03:47 +0000)] 
fix(numpy): fix dumpers registration order

If numpy dumpers are registered after numeric ones, then NPNumericBinaryDumper
is used instead of NumericBinaryDumper when looking up by oid. This
breaks dumping values with a decimal part.

23 months agotest(numpy): consolidate numpy float tests
Daniele Varrazzo [Fri, 16 Dec 2022 20:23:28 +0000 (20:23 +0000)] 
test(numpy): consolidate numpy float tests

23 months agotest(numpy): add random tests with numpy objects
Daniele Varrazzo [Fri, 16 Dec 2022 19:11:19 +0000 (19:11 +0000)] 
test(numpy): add random tests with numpy objects

23 months agotest(numpy): consolidate all numpy int tests in a single parametrized one
Daniele Varrazzo [Fri, 16 Dec 2022 18:26:23 +0000 (18:26 +0000)] 
test(numpy): consolidate all numpy int tests in a single parametrized one

23 months agotest(faker): don't crash if a lazy-import dumper class is not available
Daniele Varrazzo [Fri, 16 Dec 2022 18:24:02 +0000 (18:24 +0000)] 
test(faker): don't crash if a lazy-import dumper class is not available

23 months agofeat(numpy): add longlong dumpers
Daniele Varrazzo [Fri, 16 Dec 2022 18:23:19 +0000 (18:23 +0000)] 
feat(numpy): add longlong dumpers

23 months agorefactor(numpy): reuse base or final classes from builtin numeric types
Daniele Varrazzo [Fri, 16 Dec 2022 16:49:32 +0000 (16:49 +0000)] 
refactor(numpy): reuse base or final classes from builtin numeric types

23 months agorefactor(numpy): drop aliases for dumpers
Daniele Varrazzo [Fri, 16 Dec 2022 16:31:59 +0000 (16:31 +0000)] 
refactor(numpy): drop aliases for dumpers

Leave only one class per target PostgreSQL type and map the Python type
to the smallest type fitting the whole domain.

23 months agorefactor(numpy): use builtin bool dumpers for numpy booleans too
Daniele Varrazzo [Fri, 16 Dec 2022 16:21:36 +0000 (16:21 +0000)] 
refactor(numpy): use builtin bool dumpers for numpy booleans too

23 months agotest(numpy) fix tests with approximative comparisons
Daniele Varrazzo [Fri, 16 Dec 2022 16:17:02 +0000 (16:17 +0000)] 
test(numpy) fix tests with approximative comparisons

23 months agorefactor(numpy): use existing numeric base classes
Daniele Varrazzo [Fri, 16 Dec 2022 15:45:19 +0000 (15:45 +0000)] 
refactor(numpy): use existing numeric base classes

23 months agotest(numpy): fix skipping tests if numpy module is not installed
Daniele Varrazzo [Fri, 16 Dec 2022 15:36:45 +0000 (15:36 +0000)] 
test(numpy): fix skipping tests if numpy module is not installed

23 months agofeat: add numpy dumpers for int, float, bool types
Vertemati Francesco [Tue, 5 Jul 2022 15:37:32 +0000 (11:37 -0400)] 
feat: add numpy dumpers for int, float, bool types

Close #192.

23 months agochore: bump psycopg package version to 3.1.10
Daniele Varrazzo [Fri, 4 Aug 2023 14:55:12 +0000 (15:55 +0100)] 
chore: bump psycopg package version to 3.1.10

23 months agochore: upgrade cibuildwheel
Daniele Varrazzo [Fri, 4 Aug 2023 15:06:01 +0000 (16:06 +0100)] 
chore: upgrade cibuildwheel

23 months agochore: bump libpq, openssl used in binary packages
Daniele Varrazzo [Fri, 4 Aug 2023 15:02:29 +0000 (16:02 +0100)] 
chore: bump libpq, openssl used in binary packages

23 months agoMerge branch 'pipeline-nextset-error'
Daniele Varrazzo [Wed, 2 Aug 2023 17:17:31 +0000 (18:17 +0100)] 
Merge branch 'pipeline-nextset-error'

23 months agofix: drop error using nextset() in pipeline mode 614/head
Daniele Varrazzo [Wed, 2 Aug 2023 13:33:43 +0000 (14:33 +0100)] 
fix: drop error using nextset() in pipeline mode

Now that the behaviour of pipeline is the same of non-pipeline, raising
an exception on nextset is a difference in behaviour we can probably
drop.

23 months agofix!: only keep results of last execute() by a cursor in pipeline mode
Denis Laxalde [Mon, 31 Jul 2023 14:13:58 +0000 (16:13 +0200)] 
fix!: only keep results of last execute() by a cursor in pipeline mode

The assertion on fetchall() in 'test_execute_nextset_error' now passes.

Fixes #604.

23 months agofix: raise an error instead of a warning using nextset in pipeline mode
Daniele Varrazzo [Tue, 1 Aug 2023 11:34:01 +0000 (12:34 +0100)] 
fix: raise an error instead of a warning using nextset in pipeline mode

Note: the tests, intentionally, don't pass, because they expects
execute() results to clobber the previous ones rather than accumulating.
This behaviour is to be changed in a further commit.

See #604.

23 months agofix: raise a warning if nextset is used after execute in pipeline mode
Daniele Varrazzo [Tue, 1 Aug 2023 10:57:48 +0000 (11:57 +0100)] 
fix: raise a warning if nextset is used after execute in pipeline mode

So far have accumulated results, unlike in no-pipeline mode, where
results have been discarded. But this proved to be not reliable, so we
will forbid it in 3.2.

See #604

23 months agodocs: drop example about using nextset() in pipeline mode
Daniele Varrazzo [Tue, 1 Aug 2023 11:04:33 +0000 (12:04 +0100)] 
docs: drop example about using nextset() in pipeline mode

The feature is sort of accidental, not tested, and proved to be not
reliable, so we will remove it in 3.2.

See #604.

23 months agoMark two more tests as timing-sensitive
Martin Weinelt [Wed, 2 Aug 2023 01:59:23 +0000 (03:59 +0200)] 
Mark two more tests as timing-sensitive

FAILED tests/pool/test_pool_async.py::test_reconnect[asyncio] - AssertionError: [0.11509847640991211, 0.2041318416595459, 0.40631914138793945]
FAILED tests/pool/test_pool.py::test_reconnect - ValueError: the proxy didn't start listening in time

2 years agoMerge pull request #603 from JelteF/add-close-prepared
Daniele Varrazzo [Tue, 1 Aug 2023 14:53:25 +0000 (15:53 +0100)] 
Merge pull request #603 from JelteF/add-close-prepared

Add Close wrappers to PGconn

2 years agodocs: add news entry about libp1 17 close functions support 603/head
Daniele Varrazzo [Tue, 1 Aug 2023 14:23:37 +0000 (15:23 +0100)] 
docs: add news entry about libp1 17 close functions support

2 years agotest: add CI jobs to run libpq with PG master
Jelte Fennema [Tue, 1 Aug 2023 13:07:15 +0000 (15:07 +0200)] 
test: add CI jobs to run libpq with PG master

2 years agotest: add tests for close_prepared/portal for unsupported libpq
Jelte Fennema [Tue, 1 Aug 2023 12:39:32 +0000 (14:39 +0200)] 
test: add tests for close_prepared/portal for unsupported libpq

2 years agofix: fix pq close wrappers Python implementation
Jelte Fennema [Mon, 31 Jul 2023 15:05:01 +0000 (17:05 +0200)] 
fix: fix pq close wrappers Python implementation

Co-authored-by: Denis Laxalde <denis@laxalde.org>
2 years agotest: add tests for close pq wrappers
Jelte Fennema [Tue, 25 Jul 2023 14:41:00 +0000 (16:41 +0200)] 
test: add tests for close pq wrappers

2 years agofix: add close wrappers to FinishedPGconn too
Jelte Fennema [Tue, 25 Jul 2023 14:23:28 +0000 (16:23 +0200)] 
fix: add close wrappers to FinishedPGconn too

2 years agofeat: add Close wrappers to pgconn.pyx
Jelte Fennema [Wed, 12 Jul 2023 21:41:51 +0000 (23:41 +0200)] 
feat: add Close wrappers to pgconn.pyx

2 years agodocs: fix release version of json bytes dump support
Daniele Varrazzo [Tue, 1 Aug 2023 10:11:50 +0000 (11:11 +0100)] 
docs: fix release version of json bytes dump support

It is to be released in 3.1.10, not already released in 3.1.9... See #568

2 years agoMerge branch 'py312'
Daniele Varrazzo [Tue, 1 Aug 2023 02:53:54 +0000 (03:53 +0100)] 
Merge branch 'py312'

2 years agodocs: mention Python 3.12 support in news file
Daniele Varrazzo [Tue, 1 Aug 2023 02:48:52 +0000 (03:48 +0100)] 
docs: mention Python 3.12 support in news file

2 years agoci: bump Python 3.12 test version to beta 4
Daniele Varrazzo [Mon, 31 Jul 2023 23:56:51 +0000 (00:56 +0100)] 
ci: bump Python 3.12 test version to beta 4

2 years agotest: mark tests as failing to monitoring strange behaviour with Python 3.12
Daniele Varrazzo [Wed, 24 May 2023 23:09:09 +0000 (01:09 +0200)] 
test: mark tests as failing to monitoring strange behaviour with Python 3.12

With Python 3.12a7 and Cython-3.0.0b3, these two tests fails. It seems
that when an exception is involved the __del__ method is not called.

2 years agoci: set up test grid to test Python 3.12
Daniele Varrazzo [Wed, 24 May 2023 23:14:09 +0000 (01:14 +0200)] 
ci: set up test grid to test Python 3.12

2 years agochore: declare Python 3.12 supported in classifiers
Daniele Varrazzo [Wed, 24 May 2023 23:08:50 +0000 (01:08 +0200)] 
chore: declare Python 3.12 supported in classifiers

2 years agochore: upgrade Cython to stable 3.0.0
Daniele Varrazzo [Wed, 24 May 2023 23:08:26 +0000 (01:08 +0200)] 
chore: upgrade Cython to stable 3.0.0

2 years agofix: fix "can't adapt" error message on Python 3.11
Daniele Varrazzo [Mon, 31 Jul 2023 23:49:04 +0000 (00:49 +0100)] 
fix: fix "can't adapt" error message on Python 3.11

It appeared like "using placeholder '%PyFormat.TEXT'" because of the
change in the Enum display already fixed elsewhere.

Spotted in the conversation in #611.

Also fix unneeded nested exception in the Python version of the code.

2 years agofix: fix resetting read_only/deferrable to default using None 612/head
Daniele Varrazzo [Mon, 31 Jul 2023 22:52:45 +0000 (23:52 +0100)] 
fix: fix resetting read_only/deferrable to default using None

2 years agoFix spelling in from_pg2
Šarūnas Nejus [Sun, 30 Jul 2023 14:34:30 +0000 (15:34 +0100)] 
Fix spelling in from_pg2

2 years agodocs: add clarification about transaction characteristics attributes
Daniele Varrazzo [Tue, 25 Jul 2023 14:52:00 +0000 (15:52 +0100)] 
docs: add clarification about transaction characteristics attributes

They don't affect autocommit connections as they used to in psycopg2, so
note it as a difference from psycopg2. Add more explicit warning about
this limitation.

https://www.postgresql.org/message-id/DB7PR07MB39163E0AFB907413EE5C10F68738A%40DB7PR07MB3916.eurprd07.prod.outlook.com

2 years agoMerge branch 'fix-591'
Daniele Varrazzo [Mon, 24 Jul 2023 10:18:04 +0000 (11:18 +0100)] 
Merge branch 'fix-591'

2 years agofix: fix possible errors calling __repr__ from __del__.
Daniele Varrazzo [Sun, 23 Jul 2023 19:33:05 +0000 (20:33 +0100)] 
fix: fix possible errors calling __repr__ from __del__.

The errors get ignored but print a warning on program exit and eclipse a
genuine warning.

The error is caused by the `pq.misc` module getting gc'd on interpreter
shutdown before `connection_summary()` is called. The solution is to
import `connection_summary` in the module namespace, which is similar to
the solution that proved working for #198. It is less robust than the
solution used by the Python devs to import the function in the method
via an argument default, but it should work adequately (as nobody
complained about #198 anymore).

In #591 discussion, I proposed that connection_summary is too complex to
be considered safe to call on __del__. Actually, looking at it, it seems
innocent enough, as it only calls objects methods, no functions from
module namespaces. As a consequence we assume that this commit fixes the
issue. As I can't reproduce it, will ask the OP if this is the case.

Close #591.

2 years agoMerge branch 'fix-copy-cancel-clobbering-exception'
Daniele Varrazzo [Sun, 23 Jul 2023 18:56:06 +0000 (19:56 +0100)] 
Merge branch 'fix-copy-cancel-clobbering-exception'

2 years agofix: don't clobber a Python exception on COPY FROM with QueryCanceled
Daniele Varrazzo [Fri, 21 Jul 2023 01:10:01 +0000 (02:10 +0100)] 
fix: don't clobber a Python exception on COPY FROM with QueryCanceled

We trigger the server to raise the QueryCanceled; however, the original
exception has more information (the traceback). We can consider the
server exception just a notification that cancellation worked as
expected.

This is a mild change in behaviour, as the fixed tests state. However,
raising QueryCanceled is not explicitly documented and not part of a
strict interface, so we can probably change the exception raised without
needing to wait for psycopg 4.

Close #593

2 years agoUpdate documentation related to async and Ctrl-C
James Johnston [Wed, 12 Jul 2023 00:08:10 +0000 (17:08 -0700)] 
Update documentation related to async and Ctrl-C

Now that #543 is fixed, users shouldn't need to manually set up
signal handlers to cancel operations any more.  Update the documentation
to reflect this.

2 years agochore: bump mypy to 1.4.1
Denis Laxalde [Wed, 12 Jul 2023 06:39:51 +0000 (08:39 +0200)] 
chore: bump mypy to 1.4.1

The issue previously mentioned about '# type: ignore[arg-type]' in
rows.py got resolved.

The new '# type: ignore[comparison-overlap]' in test_pipeline*.py are
due to https://github.com/python/mypy/issues/15509, a known regression
from Mypy 1.4. We use the workaround documented in the release blog post
https://mypy-lang.blogspot.com/2023/06/mypy-140-released.html (section
"Narrowing Enum Values Using “==”").

2 years agoops: fix broken build on Windows amd64
Daniele Varrazzo [Sun, 18 Jun 2023 17:18:09 +0000 (19:18 +0200)] 
ops: fix broken build on Windows amd64

2 years agodocs: fix links generation broken by sphinx_autodoc_typehints
Daniele Varrazzo [Tue, 13 Jun 2023 16:12:06 +0000 (18:12 +0200)] 
docs: fix links generation broken by sphinx_autodoc_typehints

Still don't know what we will lose in the docs, but we can clean them up
once they don't totally suck anymore.

2 years agoMark test_ctrl_c_handler as timing sensitive
Sandro [Tue, 13 Jun 2023 09:34:55 +0000 (11:34 +0200)] 
Mark test_ctrl_c_handler as timing sensitive

psycopg> =================================== FAILURES ===================================
psycopg> _____________________________ test_ctrl_c_handler ______________________________
psycopg>         t0 = time.time()
psycopg>         proc = sp.Popen([sys.executable, "-s", "-c", script], creationflags=creationflags)
psycopg>         proc.communicate()
psycopg>         t = time.time() - t0
psycopg>         assert proc.returncode == 0
psycopg> >       assert 1 < t < 2
psycopg> E       assert 3.7456982135772705 < 2
psycopg>
psycopg> tests/test_concurrency.py:293: AssertionError

2 years agodocs: add more details about getting results from executemany
Daniele Varrazzo [Tue, 13 Jun 2023 14:02:31 +0000 (16:02 +0200)] 
docs: add more details about getting results from executemany

2 years agoMerge pull request #570 from dlax/error-pgconn
Daniele Varrazzo [Tue, 13 Jun 2023 12:12:29 +0000 (14:12 +0200)] 
Merge pull request #570 from dlax/error-pgconn

finish the PGconn upon connection failure

2 years agodocs(pool): document that using idle_session_timeout is not a good idea
Daniele Varrazzo [Thu, 8 Jun 2023 14:44:53 +0000 (16:44 +0200)] 
docs(pool): document that using idle_session_timeout is not a good idea

2 years agofix(pool): check connections' max_lifetime on ``check()``
Daniele Varrazzo [Thu, 8 Jun 2023 13:56:22 +0000 (15:56 +0200)] 
fix(pool): check connections' max_lifetime on ``check()``

Close #482.

2 years agofix: finish the PGconn upon connection failure 570/head
Denis Laxalde [Fri, 19 May 2023 07:06:55 +0000 (09:06 +0200)] 
fix: finish the PGconn upon connection failure

Attaching the non-finished PGconn to exceptions raised in connect() is
causing problem, as described in issue #565, because the PGconn might
not get finished soon enough in application code and the socket would
remain open.

On the other hand, just removing the pgconn attribute from Error would
be a breaking change and we'd loose the inspection features introduced
in commit 9220293dc023b757f2a57702c14b1460ff8f25b0.

As an alternative, we define a new PGconn implementation that is
error-specific: it captures all attributes of the original PGconn and
fails upon other operations (methods call). Some attributes have a
default value since they are not available in old PostgreSQL versions.

Finally, the (real) PGconn is finished before raising exception in
generators.connect().

2 years agochore: add a trailing comma in Error.__init__() to make black happy
Denis Laxalde [Fri, 19 May 2023 07:06:55 +0000 (09:06 +0200)] 
chore: add a trailing comma in Error.__init__() to make black happy

2 years agotests: check that OperationalError raised by connect() holds a pgconn
Denis Laxalde [Tue, 16 May 2023 11:28:37 +0000 (13:28 +0200)] 
tests: check that OperationalError raised by connect() holds a pgconn

Sort of a non-regression test for the part of commit
9220293dc023b757f2a57702c14b1460ff8f25b0 concerning generators. It used
roughly the same logic as tests/pq/test_pgconn.py::test_used_password()
to determine if the test connection needs a password and gets skipped
otherwise.

2 years agoMerge pull request #586 from dlax/issue-585
Daniele Varrazzo [Mon, 12 Jun 2023 20:13:28 +0000 (22:13 +0200)] 
Merge pull request #586 from dlax/issue-585

fix: always validate PrepareManager cache in pipeline mode

2 years agofix: always validate PrepareManager cache in pipeline mode 586/head
Denis Laxalde [Thu, 8 Jun 2023 09:21:42 +0000 (11:21 +0200)] 
fix: always validate PrepareManager cache in pipeline mode

Previously, when processing results in pipeline mode
(BasePipeline._process_results()), we'd run
'cursor._check_results(results)' early before calling
_prepared.validate() with prepared statement information. However, if
this check step fails, for example if the pipeline got aborted due to a
previous error, the latter step (PrepareManager cache validation) was
not run.

We fix this by reversing the logic, and checking results last.

However, this is not enough, because the results processing logic in
BasePipeline._fetch_gen() or _communicate_gen(), which sequentially
walked through fetched results, would typically stop at the first
exception and thus possibly never go through the step of validating
PrepareManager cache if a previous error happened.

We fix that by making sure that *all* results are processed, possibly
capturing the first exception and then re-raising it. In both
_communicate_gen() and _fetch_gen(), we no longer store results in the
'to_process' like, but process then upon reception as this logic is no
longer needed.

Fix #585.

2 years agodocs: adjust PrepareManager.validate() docstring
Denis Laxalde [Thu, 8 Jun 2023 12:03:18 +0000 (14:03 +0200)] 
docs: adjust PrepareManager.validate() docstring

From commit bfabe88aba4769e0a44206e1ace7c299991a957d, the method does
not return a command, but it records it through _rotate().

2 years agodocs: remove outdated comments in PrepareManager's docstrings
Denis Laxalde [Thu, 8 Jun 2023 11:38:44 +0000 (13:38 +0200)] 
docs: remove outdated comments in PrepareManager's docstrings

PrepareManager's methods maybe_add_to_cache() and validate() are said to
only be used in pipeline mode, but this is wrong as can be seen in
BaseCursor._maybe_prepare_gen(). (Comments are probably a left-over from
a prior implementation of the pipeline mode.)

2 years agodocs: add notes about using IS with placeholders
Daniele Varrazzo [Sun, 4 Jun 2023 23:18:03 +0000 (01:18 +0200)] 
docs: add notes about using IS with placeholders

See #582.

2 years agoMerge pull request #568 from lionel-panhaleux/master
Daniele Varrazzo [Sun, 4 Jun 2023 22:29:27 +0000 (00:29 +0200)] 
Merge pull request #568 from lionel-panhaleux/master

Allow binary JSON dumps

2 years agofeat: allow binary JSON dumps 568/head
Lionel Panhaleux [Fri, 19 May 2023 12:03:29 +0000 (14:03 +0200)] 
feat: allow binary JSON dumps

Some JSON libraries, in particular the widespread
[orjson](https://github.com/ijl/orjson#quickstart) library, directly
dump data in binary format.

This change allows it and avoids having to decode/encode in these cases
by testing the return type of the `dumps` function.

2 years agodocs: add info about DateStyle support
Daniele Varrazzo [Mon, 22 May 2023 00:15:28 +0000 (02:15 +0200)] 
docs: add info about DateStyle support

Close #571

2 years agodocs: add note regarding the differences in date/time domains
Daniele Varrazzo [Tue, 16 May 2023 00:17:51 +0000 (02:17 +0200)] 
docs: add note regarding the differences in date/time domains

2 years agoAdded minimal Django integration tests.
Florian Apolloner [Sat, 15 Apr 2023 08:13:34 +0000 (10:13 +0200)] 
Added minimal Django integration tests.

2 years agochore: bump psycopg package version to 3.1.9
Daniele Varrazzo [Tue, 2 May 2023 10:56:24 +0000 (12:56 +0200)] 
chore: bump psycopg package version to 3.1.9

2 years agoMerge pull request #551 from psycopg/fix-json-dump-dict
Daniele Varrazzo [Tue, 2 May 2023 10:16:59 +0000 (12:16 +0200)] 
Merge pull request #551 from psycopg/fix-json-dump-dict

fix(json): allow to register json dumpers on dict or other objects

2 years agotest(json): fix dict registration test on crdb 551/head
Daniele Varrazzo [Mon, 17 Apr 2023 21:52:06 +0000 (23:52 +0200)] 
test(json): fix dict registration test on crdb

2 years agofix(json): allow to register json dumpers on dict or other objects
Daniele Varrazzo [Mon, 10 Apr 2023 20:55:44 +0000 (22:55 +0200)] 
fix(json): allow to register json dumpers on dict or other objects

2 years agofix: don't reuse the same Transformer in composite dumper
Daniele Varrazzo [Sun, 16 Apr 2023 01:30:37 +0000 (03:30 +0200)] 
fix: don't reuse the same Transformer in composite dumper

We need different dumpers because, in case a composite contains another
composite, we need to call `dump_sequence()` on different sequences, so
we row dumpers must be distinct.

Close #547

2 years agodocs: fix cursor -> connection in the context of transaction management
Daniele Varrazzo [Thu, 13 Apr 2023 21:23:14 +0000 (23:23 +0200)] 
docs: fix cursor -> connection in the context of transaction management

Close #548