]> git.ipfire.org Git - thirdparty/psycopg.git/log
thirdparty/psycopg.git
5 years agoMore care in None return values from libpq result functions
Daniele Varrazzo [Sat, 11 Apr 2020 06:03:26 +0000 (18:03 +1200)] 
More care in None return values from libpq result functions

5 years agoAdded barebone implementation of dbapi 2.0
Daniele Varrazzo [Sat, 11 Apr 2020 04:54:47 +0000 (16:54 +1200)] 
Added barebone implementation of dbapi 2.0

Several methods not tested yet, fetch method not added yet to async
cursor.

5 years agoFixed some shenanigan around connection params
Daniele Varrazzo [Sat, 11 Apr 2020 02:20:15 +0000 (14:20 +1200)] 
Fixed some shenanigan around connection params

The libpq function return None for an invalid connection: take that into
account in the function signature and usage.

Dropped asymmetry between sync and async connection for the encoding
setter: use for both a set_client_encoding() function. This way it's
easy to keep the getter on the base class.

5 years agoThe big rename: adapters -> dumpers, typecasters -> loaders.
Daniele Varrazzo [Thu, 9 Apr 2020 07:12:52 +0000 (19:12 +1200)] 
The big rename: adapters -> dumpers, typecasters -> loaders.

5 years agoFixed composite info query to work for pg <= 10
Daniele Varrazzo [Thu, 9 Apr 2020 00:41:56 +0000 (12:41 +1200)] 
Fixed composite info query to work for pg <= 10

creating a row() on the fly caused the error "record type has not been
registered"

5 years agoAdded tuple text adaptation
Daniele Varrazzo [Wed, 8 Apr 2020 15:52:15 +0000 (03:52 +1200)] 
Added tuple text adaptation

It cannot return a record oid, Postgres is not happy to parse it, so
return it as text.

5 years agoFixed formats in query with repeated arguments
Daniele Varrazzo [Wed, 8 Apr 2020 15:48:11 +0000 (03:48 +1200)] 
Fixed formats in query with repeated arguments

Fixed test that wasn't checking the format.

5 years agoAdded composite.fetch_info_async
Daniele Varrazzo [Wed, 8 Apr 2020 10:10:45 +0000 (22:10 +1200)] 
Added composite.fetch_info_async

5 years agofetchone() made async on async cursor
Daniele Varrazzo [Wed, 8 Apr 2020 10:10:12 +0000 (22:10 +1200)] 
fetchone() made async on async cursor

5 years agoregister_array() renamed to array.register()
Daniele Varrazzo [Wed, 8 Apr 2020 09:59:47 +0000 (21:59 +1200)] 
register_array() renamed to array.register()

5 years agoFixed registration scope of composite array adapters
Daniele Varrazzo [Wed, 8 Apr 2020 09:55:37 +0000 (21:55 +1200)] 
Fixed registration scope of composite array adapters

5 years agoAdded typecasting of composite types
Daniele Varrazzo [Wed, 8 Apr 2020 09:00:16 +0000 (21:00 +1200)] 
Added typecasting of composite types

5 years agoAdded cast from varchar, bpchar, name
Daniele Varrazzo [Wed, 8 Apr 2020 06:15:36 +0000 (18:15 +1200)] 
Added cast from varchar, bpchar, name

Note that bpchar (i.e. the output format for "char" - with quotes) and
name are always decoded, even if the db is SQL_ASCII, because these
types are mostly used in system catalogs and there should be no such
crap as unencded data there.

5 years agoAdded tests for all numeric types arrays
Daniele Varrazzo [Tue, 7 Apr 2020 14:30:33 +0000 (02:30 +1200)] 
Added tests for all numeric types arrays

5 years agoDropped ArrayCaster, expose register_array function instead
Daniele Varrazzo [Tue, 7 Apr 2020 12:39:37 +0000 (00:39 +1200)] 
Dropped ArrayCaster, expose register_array function instead

The function only associates array_oid -> base_oid. Looking up the right
typecaster happens at cast time: this way composite adapters (record,
list) can use the caster register in the right context.

All the types for which there is an adapter gets an array caster now.

5 years agoReally use the context to transform components types
Daniele Varrazzo [Tue, 7 Apr 2020 11:18:59 +0000 (23:18 +1200)] 
Really use the context to transform components types

It works for arrays and records, except for text arrays because the
decorator registers the TypeCaster directly, not the oid. This must
change, we need a different decorator/registration.

5 years agoThe Transformer is an adaptation context
Daniele Varrazzo [Tue, 7 Apr 2020 10:24:09 +0000 (22:24 +1200)] 
The Transformer is an adaptation context

Dropped cursor from Adapter, TypeCaster, Transformer. Added adapters and
casters map on Trasformer.

Solves a problem of customization in composite types: if a type is
customized now composite types containing that type use the same
customization. Also fixed a circular reference between transformer and
cursor.

5 years agoWork around mypy error of Format not exposed by psycopg3.adapt
Daniele Varrazzo [Tue, 7 Apr 2020 09:26:49 +0000 (21:26 +1200)] 
Work around mypy error of Format not exposed by psycopg3.adapt

5 years agoAdded binary cast of record type
Daniele Varrazzo [Tue, 7 Apr 2020 09:23:42 +0000 (21:23 +1200)] 
Added binary cast of record type

5 years agoAdded Transformer.cast_sequence() in place of cast_row()
Daniele Varrazzo [Tue, 7 Apr 2020 08:51:52 +0000 (20:51 +1200)] 
Added Transformer.cast_sequence() in place of cast_row()

The function is more generic and the Transformer doesn't have to wrap a
PGresult anymore.

5 years agoAdded text cast of records
Daniele Varrazzo [Tue, 7 Apr 2020 06:44:04 +0000 (18:44 +1200)] 
Added text cast of records

5 years agoDropped accepting None as Transformer.cast() input
Daniele Varrazzo [Tue, 7 Apr 2020 06:43:00 +0000 (18:43 +1200)] 
Dropped accepting None as Transformer.cast() input

More efficient if we only accept non-null results.

5 years agoLess global objects in types.array module
Daniele Varrazzo [Tue, 7 Apr 2020 03:26:28 +0000 (15:26 +1200)] 
Less global objects in types.array module

5 years agoAdded xfailing tests to remember what is left to implement
Daniele Varrazzo [Sun, 5 Apr 2020 05:37:05 +0000 (17:37 +1200)] 
Added xfailing tests to remember what is left to implement

5 years agoCleanup of the array adapter algorithm
Daniele Varrazzo [Sun, 5 Apr 2020 04:44:31 +0000 (16:44 +1200)] 
Cleanup of the array adapter algorithm

5 years agoCheck that arrays contain consistent objects.
Daniele Varrazzo [Sun, 5 Apr 2020 02:07:04 +0000 (14:07 +1200)] 
Check that arrays contain consistent objects.

5 years agoDropped spurious comment
Daniele Varrazzo [Sun, 5 Apr 2020 01:20:21 +0000 (13:20 +1200)] 
Dropped spurious comment

5 years agoAdded adaptation of binary arrays
Daniele Varrazzo [Sun, 5 Apr 2020 01:10:44 +0000 (13:10 +1200)] 
Added adaptation of binary arrays

Added binary array adaptation for test types and some numeric types.

5 years agoConsistent name of 'format' parameter
Daniele Varrazzo [Sat, 4 Apr 2020 15:27:12 +0000 (03:27 +1200)] 
Consistent name of 'format' parameter

Also really use function caches in Transformer

5 years agoConsistent 'src' name for the first argument of the adapters
Daniele Varrazzo [Sat, 4 Apr 2020 15:14:08 +0000 (03:14 +1200)] 
Consistent 'src' name for the first argument of the adapters

'cls' is messy when it comes to class methods.

5 years agoAdded cast of binary arrays
Daniele Varrazzo [Sat, 4 Apr 2020 14:12:10 +0000 (02:12 +1200)] 
Added cast of binary arrays

5 years agoFixed typing typo
Daniele Varrazzo [Sat, 4 Apr 2020 09:19:21 +0000 (22:19 +1300)] 
Fixed typing typo

5 years agoAdaptation context transferred to the adapters objects
Daniele Varrazzo [Fri, 3 Apr 2020 14:23:33 +0000 (03:23 +1300)] 
Adaptation context transferred to the adapters objects

5 years agoUse classmethod instead of staticmethod to play better with inheritance
Daniele Varrazzo [Fri, 3 Apr 2020 13:04:35 +0000 (02:04 +1300)] 
Use classmethod instead of staticmethod to play better with inheritance

5 years agoAdded array tests for sql_ascii db and bytea
Daniele Varrazzo [Fri, 3 Apr 2020 12:53:35 +0000 (01:53 +1300)] 
Added array tests for sql_ascii db and bytea

5 years agoFixed TypeCasterType and AdapterType types
Daniele Varrazzo [Fri, 3 Apr 2020 11:58:34 +0000 (00:58 +1300)] 
Fixed TypeCasterType and AdapterType types

The previous signature meant an instance of Adapter/TypeCaster or a function,
but we meant a class actually. The error costed some cursing and some
casting to the right type (in mypy sense, not in psyco sense)

5 years agoAdded wrapper for escape_bytea with no connection
Daniele Varrazzo [Fri, 3 Apr 2020 11:57:21 +0000 (00:57 +1300)] 
Added wrapper for escape_bytea with no connection

Changed unescape_bytea to be a normal method. The pgconn is now
optional.

5 years agoTypecaster renamed to TypeCaster
Daniele Varrazzo [Fri, 3 Apr 2020 11:19:46 +0000 (00:19 +1300)] 
Typecaster renamed to TypeCaster

Because I have ArrayCaster, will have RangeCaster etc.

5 years agoAdded basic array adaptation infrastructure
Daniele Varrazzo [Fri, 3 Apr 2020 11:17:31 +0000 (00:17 +1300)] 
Added basic array adaptation infrastructure

5 years agoFixed names of wrapper functions
Daniele Varrazzo [Fri, 3 Apr 2020 11:09:16 +0000 (00:09 +1300)] 
Fixed names of wrapper functions

5 years agoAdded object to map oid and data types
Daniele Varrazzo [Fri, 3 Apr 2020 00:27:59 +0000 (13:27 +1300)] 
Added object to map oid and data types

5 years agoAdded array delimiter to the data types info
Daniele Varrazzo [Thu, 2 Apr 2020 23:32:58 +0000 (12:32 +1300)] 
Added array delimiter to the data types info

5 years agoCleanup of the encodings table and lookup
Daniele Varrazzo [Thu, 2 Apr 2020 15:09:51 +0000 (04:09 +1300)] 
Cleanup of the encodings table and lookup

5 years agoHandle sql_ascii encoding as binary
Daniele Varrazzo [Thu, 2 Apr 2020 14:57:09 +0000 (03:57 +1300)] 
Handle sql_ascii encoding as binary

5 years agoAdded pq.Escaping object and bytea adaptation
Daniele Varrazzo [Thu, 2 Apr 2020 13:59:35 +0000 (02:59 +1300)] 
Added pq.Escaping object and bytea adaptation

5 years agoAdded connection.encoding
Daniele Varrazzo [Thu, 2 Apr 2020 12:26:57 +0000 (01:26 +1300)] 
Added connection.encoding

5 years agoAdded bytes adaptation
Daniele Varrazzo [Thu, 2 Apr 2020 09:19:47 +0000 (22:19 +1300)] 
Added bytes adaptation

5 years agoAdded binary typecasting of int, float, bool.
Daniele Varrazzo [Thu, 2 Apr 2020 05:55:10 +0000 (18:55 +1300)] 
Added binary typecasting of int, float, bool.

5 years ago'pgresult' is part of the Cursor interface
Daniele Varrazzo [Thu, 2 Apr 2020 05:04:33 +0000 (18:04 +1300)] 
'pgresult' is part of the Cursor interface

The same way 'pgconn' is a public property of the Connection.

5 years agoModules import to register builtin types moved to types package
Daniele Varrazzo [Thu, 2 Apr 2020 04:44:44 +0000 (17:44 +1300)] 
Modules import to register builtin types moved to types package

5 years agoexceptions module renamed to errors
Daniele Varrazzo [Thu, 2 Apr 2020 02:29:52 +0000 (15:29 +1300)] 
exceptions module renamed to errors

To be part of the public interface, for compatibility with psycopg2

5 years agoModule adaptation renamed to adapt
Daniele Varrazzo [Thu, 2 Apr 2020 01:58:46 +0000 (14:58 +1300)] 
Module adaptation renamed to adapt

I figure out this is part of the external interface. Let's give it a
nice name.

5 years agoAdded text types conversion for numeric types and bools
Daniele Varrazzo [Thu, 2 Apr 2020 01:35:55 +0000 (14:35 +1300)] 
Added text types conversion for numeric types and bools

Plenty of tests, too.

5 years agoAdded tests about adapters/casters selection, some fixes
Daniele Varrazzo [Wed, 1 Apr 2020 13:25:58 +0000 (02:25 +1300)] 
Added tests about adapters/casters selection, some fixes

- Added Transformer.cast() function;
- Can return binary results even with no input parameters;
- libpq functions accept sequences rather than lists.

5 years agoInclude None in AdaptContext
Daniele Varrazzo [Wed, 1 Apr 2020 11:59:01 +0000 (00:59 +1300)] 
Include None in AdaptContext

Using Union[None...] instead of Optional[... is a choice. None has a
meaning, it means global, not optional.

5 years agoDefinition with a wrong default changed into declaration
Daniele Varrazzo [Tue, 31 Mar 2020 16:43:04 +0000 (05:43 +1300)] 
Definition with a wrong default changed into declaration

5 years agoAdded mypy tests on travis
Daniele Varrazzo [Tue, 31 Mar 2020 08:28:09 +0000 (21:28 +1300)] 
Added mypy tests on travis

5 years agoAdded install instruction to readme
Daniele Varrazzo [Tue, 31 Mar 2020 06:07:39 +0000 (19:07 +1300)] 
Added install instruction to readme

5 years agoUse == instead of is to check the Wait states
Daniele Varrazzo [Tue, 31 Mar 2020 05:56:11 +0000 (18:56 +1300)] 
Use == instead of is to check the Wait states

Now they are integers so is, while it works, is an implementation
detail.

5 years agoUse the selectors module instead of select
Daniele Varrazzo [Tue, 31 Mar 2020 05:45:08 +0000 (18:45 +1300)] 
Use the selectors module instead of select

Choose a better way to wait for readyness than select if available.

Also fixed an error in both sync and async waiting: don't discard the
result of send().

5 years agosetup.py fixed
Daniele Varrazzo [Tue, 31 Mar 2020 02:16:02 +0000 (15:16 +1300)] 
setup.py fixed

Sub-packages weren't installed. Now it should be possible to install it
using:

    pip install "git+https://github.com/psycopg/psycopg3.git#egg=psycopg3"

Note that it was already possible to do so using

    pip install -e "git+https://github.com/psycopg/psycopg3.git#egg=psycopg3"

5 years agoAdded license
Daniele Varrazzo [Tue, 31 Mar 2020 02:15:35 +0000 (15:15 +1300)] 
Added license

5 years agoAdded types stub for ctypes functions
Daniele Varrazzo [Mon, 30 Mar 2020 15:21:36 +0000 (04:21 +1300)] 
Added types stub for ctypes functions

5 years agoAnother couple of functions marked as returning Oid
Daniele Varrazzo [Sun, 29 Mar 2020 16:11:27 +0000 (05:11 +1300)] 
Another couple of functions marked as returning Oid

5 years agoSolved problem with namedtuple index
Daniele Varrazzo [Sun, 29 Mar 2020 15:45:45 +0000 (04:45 +1300)] 
Solved problem with namedtuple index

There's already a method index on the nametuple :D

5 years agoAdded Oid type
Daniele Varrazzo [Sun, 29 Mar 2020 15:36:14 +0000 (04:36 +1300)] 
Added Oid type

5 years agoFixed problem with adapters decorators
Daniele Varrazzo [Sun, 29 Mar 2020 15:18:19 +0000 (04:18 +1300)] 
Fixed problem with adapters decorators

Now mypy --strict passes 100%

5 years agoAdded most type annotations
Daniele Varrazzo [Sun, 29 Mar 2020 14:39:21 +0000 (03:39 +1300)] 
Added most type annotations

mypy almost passes in --strict mode

5 years agoAlso run mypy on tests and setup
Daniele Varrazzo [Sun, 29 Mar 2020 05:24:10 +0000 (18:24 +1300)] 
Also run mypy on tests and setup

Added mypy config to tox.ini

5 years agoFirst pass of mypy annotation
Daniele Varrazzo [Sun, 29 Mar 2020 05:03:07 +0000 (18:03 +1300)] 
First pass of mypy annotation

Just fix what doesn't make mypy happy

5 years agoDropped local encoder/decoder in int adapters
Daniele Varrazzo [Sun, 29 Mar 2020 02:18:38 +0000 (15:18 +1300)] 
Dropped local encoder/decoder in int adapters

Premature optimization, and leaks in the globals adapters maps, which
are otherwise very readable in modern Python versions.

5 years agoOid map updated to PG 12
Daniele Varrazzo [Sun, 29 Mar 2020 01:47:11 +0000 (14:47 +1300)] 
Oid map updated to PG 12

5 years agoINVALID_OID moved to oids module
Daniele Varrazzo [Sun, 29 Mar 2020 01:40:10 +0000 (14:40 +1300)] 
INVALID_OID moved to oids module

5 years agoFixed oids order
Daniele Varrazzo [Sun, 29 Mar 2020 01:39:04 +0000 (14:39 +1300)] 
Fixed oids order

5 years agoAdded regtype spelling of data types to oid table
Daniele Varrazzo [Sat, 28 Mar 2020 15:31:31 +0000 (04:31 +1300)] 
Added regtype spelling of data types to oid table

5 years agoAdapter/caster register functions can be used as decorators
Daniele Varrazzo [Sat, 28 Mar 2020 15:02:51 +0000 (04:02 +1300)] 
Adapter/caster register functions can be used as decorators

5 years agoregister function and global adapters map moved as class members
Daniele Varrazzo [Sat, 28 Mar 2020 14:54:21 +0000 (03:54 +1300)] 
register function and global adapters map moved as class members

5 years agoAdapters moved to the types package
Daniele Varrazzo [Sat, 28 Mar 2020 14:45:09 +0000 (03:45 +1300)] 
Adapters moved to the types package

5 years agoAdded map of types oids
Daniele Varrazzo [Sat, 28 Mar 2020 14:31:13 +0000 (03:31 +1300)] 
Added map of types oids

5 years agoAdded adapter/caster decorators
Daniele Varrazzo [Sat, 28 Mar 2020 12:06:09 +0000 (01:06 +1300)] 
Added adapter/caster decorators

5 years agoAdded register_adapter/caster functions
Daniele Varrazzo [Sat, 28 Mar 2020 11:50:19 +0000 (00:50 +1300)] 
Added register_adapter/caster functions

5 years agoMaking adapters/casters simpler
Daniele Varrazzo [Sat, 28 Mar 2020 11:22:20 +0000 (00:22 +1300)] 
Making adapters/casters simpler

It can be either a function or an Adapter/Typecaster instance, in case
configuration based on class/oid/connection is required.

Adapter functions can optionally return an oid.

5 years agoSeparate Transformer into Adapter and Typecaster
Daniele Varrazzo [Sat, 28 Mar 2020 09:52:41 +0000 (22:52 +1300)] 
Separate Transformer into Adapter and Typecaster

There isn't much sense to have a single, more complex object, doing two
potentially unrelated things.

5 years agoAdded binary results from cursor
Daniele Varrazzo [Fri, 27 Mar 2020 13:02:10 +0000 (02:02 +1300)] 
Added binary results from cursor

5 years agoAdded basic typecasting and cursor.fetchone()
Daniele Varrazzo [Fri, 27 Mar 2020 12:26:57 +0000 (01:26 +1300)] 
Added basic typecasting and cursor.fetchone()

5 years agoAdded sketch of adaptation layer
Daniele Varrazzo [Fri, 27 Mar 2020 09:02:42 +0000 (22:02 +1300)] 
Added sketch of adaptation layer

5 years agoAdded format enum
Daniele Varrazzo [Fri, 27 Mar 2020 08:13:46 +0000 (21:13 +1300)] 
Added format enum

5 years agoquery2pg returns formats too
Daniele Varrazzo [Fri, 27 Mar 2020 07:22:42 +0000 (20:22 +1300)] 
query2pg returns formats too

5 years agoAllow b and s formats on query split
Daniele Varrazzo [Fri, 27 Mar 2020 06:55:43 +0000 (19:55 +1300)] 
Allow b and s formats on query split

5 years agoVerbose regexp to parse placeholders
Daniele Varrazzo [Fri, 27 Mar 2020 06:38:35 +0000 (19:38 +1300)] 
Verbose regexp to parse placeholders

5 years agoTypoeoes
Daniele Varrazzo [Thu, 26 Mar 2020 13:19:41 +0000 (02:19 +1300)] 
Typoeoes

5 years agoSkip certain tests on PG < 10
Daniele Varrazzo [Tue, 24 Mar 2020 11:34:11 +0000 (00:34 +1300)] 
Skip certain tests on PG < 10

The server raises "could not determine data type" for pretty simple
queries of the form "select $1, $2, $3"

Should ask the PG devs if there is a workaround short of knowing the
oids.

5 years agoDisplay libpq version on test header
Daniele Varrazzo [Tue, 24 Mar 2020 11:22:44 +0000 (00:22 +1300)] 
Display libpq version on test header

Trying to work out which version is failing.

5 years agotmp
Daniele Varrazzo [Tue, 24 Mar 2020 10:48:36 +0000 (23:48 +1300)] 
tmp

5 years agoSkip test for waiting on send
Daniele Varrazzo [Tue, 24 Mar 2020 10:29:55 +0000 (23:29 +1300)] 
Skip test for waiting on send

It doesn't seem reliable

5 years agoAdded class_for_state() stub
Daniele Varrazzo [Tue, 24 Mar 2020 10:19:22 +0000 (23:19 +1300)] 
Added class_for_state() stub

5 years agoSkip hostaddr test for PG version < 12
Daniele Varrazzo [Tue, 24 Mar 2020 10:14:34 +0000 (23:14 +1300)] 
Skip hostaddr test for PG version < 12

5 years agoUse 'async with lock' instead of deprecated 'with await lock'
Daniele Varrazzo [Tue, 24 Mar 2020 07:51:52 +0000 (20:51 +1300)] 
Use 'async with lock' instead of deprecated 'with await lock'

5 years agoAdded PQlibVersion() wrapper
Daniele Varrazzo [Tue, 24 Mar 2020 07:44:08 +0000 (20:44 +1300)] 
Added PQlibVersion() wrapper

Skip importing PQhostaddr from libpq version where it's not available.

5 years agoFlake8 config tweaked for black compatibility
Daniele Varrazzo [Tue, 24 Mar 2020 07:18:41 +0000 (20:18 +1300)] 
Flake8 config tweaked for black compatibility