Daniele Varrazzo [Tue, 24 May 2022 13:05:13 +0000 (15:05 +0200)]
test: fix skipping versions in parametrized tests
In the previous implementation, all the tests were skipped, because
annotations were added to the function and ended up affecting all
generated tests, not the marked ones only.
Daniele Varrazzo [Sun, 22 May 2022 00:44:17 +0000 (02:44 +0200)]
fix(crdb): fix json adaptation
The function set_json_dumps() now adapts the currently registered
adapter, not the default one, to be able to customize the Json dumper on
CRDB, without resetting its oid to the PostgreSQL standard one, which
CRDB doesn't know.
Daniele Varrazzo [Fri, 20 May 2022 00:32:19 +0000 (02:32 +0200)]
test(crdb): add copy tests
Skip tests from psycopg, because there is no support for copy out and
copy in syntax is different. Data types are different too (int/serial
mean int8) so the binary data samples don't match the format.
Daniele Varrazzo [Tue, 17 May 2022 00:28:53 +0000 (02:28 +0200)]
feat(crdb): cusomize CockroachDB connection
- Add ConnectionInfo.vendor
- Add ConnectionInfo subclassing
- Add CrdbConnectionInfo subclass with crdb_version attribute
- Add 'psycopg.crdb' module with adapters
- Dump strings using the text oid by default on CockroachDB
The latter change might have wider consequences, however crdb casts
strings to other types more easily than what Postgres does. At a glance
it might work; porting the rest of the test suite will tell.
test_adapt tests ported. Tests showing a difference moved to
crdb/test_adapt.
Daniele Varrazzo [Mon, 27 Jun 2022 21:32:20 +0000 (22:32 +0100)]
fix: clean internal use of LiteralString
Tested one-off using pyre 0.9.13; however it gives too many differences
compared to mypy to use it at the moment.
The pyre run doesn't currently find LiteralString-related problems,
except the todo at psycopg/sql.py:251, because string.Formatter.parse()
doesn't return a LiteralString upon LiteralString input.
feat: don't block on address resolution in async connections
Use the same algorithm implemented in the `_dns` module, but based on
asyncio getaddrinfo: this avoids the need of the external dns package
and works correctly with the /etc/hosts file.
There were problems of resource leaking in Python 3.6, but as psycopg
3.1 is 3.7+ only, let's go for it!
Daniele Varrazzo [Sun, 12 Jun 2022 09:09:42 +0000 (11:09 +0200)]
fix: sync pipeline before rollback()
We were syncing it already, but only if we had received a "pipeline
aborted" already. This might be not the case, as probably the tests
test_errors_raised_on_commit which has been failing in CI randomly for
weeks has been trying to say. Other similar branches (e.g. on commit)
don't have the same check for aborted state.
fix: produce consistent error messages on date overflow
- State if the date is too small or too large, not just "not supported".
- Use similar messages in text and binary format.
- Avoid an overflow error with the infinity date in Python.
refactor: rename the no_pqexec param to force_extended
This refers to using the extended query protocol even in cases where the
singe query protocol might have been chosen instead (e.g. because we
don't have parameters to send).
The negative in the param name is confusing, and the reference to the
PQexec function is wrong, because we never use that function (which is
blocking), but rather we choose PQsendQueryParams instead of
PQsendQuery.
There is no reason to use it: the only reason to not use
PQsendQueryParams is to send multiple statements, but this is not
possible in pipeline mode anyway.
Using PQsendQuery seems to produce a spurious Close message, which the
libpq is surprised to receive. Issue reported to pgsql-bugs.
Denis Laxalde [Wed, 25 May 2022 06:51:05 +0000 (08:51 +0200)]
fix: sync nested pipeline with pending commands upon enter
When entering a nested pipeline and the outer one has pending commands,
we now sync the pipeline. This is probably less surprising at it makes
the implicit transaction from a nested pipeline isolated from the outer
one.
With this, the explicit Sync when entering a transaction is no longer
needed.
Daniele Varrazzo [Sun, 22 May 2022 00:08:03 +0000 (02:08 +0200)]
fix: don't add a cast to text literals
Normally cast is not added to unknown literals, and the text oid is not
usually used. However, when it is, it causes problems. Often Postgres
wants just a literal, not a cast type; for instance, this is not valid:
Daniele Varrazzo [Thu, 19 May 2022 21:41:26 +0000 (23:41 +0200)]
Test: fix mypy 0.941 run
This seems a mypy shortcoming fixed in 0.950 as the CI didn't complain.
The row factory definition was exotic but arguably correct. Not worth
bumping up the min version for it anyway.
Denis Laxalde [Mon, 16 May 2022 17:16:53 +0000 (19:16 +0200)]
fix: only use covariant Row type variable
The real variance of Row type variable is covariant, per definition of
RowMaker (RowMaker[B] is a subtype of RowMaker[A] if B is a subtype of
A; similar to the Box type in [mypy documentation][]).
By dropping the Row type variable from Cursor argument in RowFactory, we
are now able to only use the covariant Row variable (previously Row_co,
now Row). Indeed, RowFactory does not actually depend on Cursor on being
parametrized on Row; rather it's the other way around (Cursor's Row type
variable comes from its row factory).
Denis Laxalde [Sun, 15 May 2022 12:28:36 +0000 (14:28 +0200)]
fix: use a more generic connection type in {Client,Server}Cursor
This makes them similar to plain Cursor class, i.e. being parametrized
on sync or async connection type, not the row type (which is handled
through the second type variable).