72 Commits

Author SHA1 Message Date
Jack Christensen
2f6fcf8eb0 RowTo(AddrOf)StructByPos ignores fields with "-" db tag
https://github.com/jackc/pgx/discussions/1682
2023-07-15 09:39:20 -05:00
Jack Christensen
91cba90e8d Fix: RowScanner errors are fatal to Rows
https://github.com/jackc/pgx/issues/1654
2023-06-20 08:48:06 -05:00
Jack Christensen
5f28621394 Add docs clarifying that FieldDescriptions may return nil
https://github.com/jackc/pgx/issues/1634
2023-06-14 07:42:11 -05:00
Jack Christensen
f59e8bf555 Fix: RowToStructByPos with embedded unexported struct
https://github.com/jackc/pgx/issues/1583
2023-04-27 21:03:58 -05:00
Audi P. Risa P
7555c43033 add lax field to namedStructRowScanner 2023-03-25 09:57:38 -05:00
Audi P. Risa P
193bab416f add RowTo(AddrOf)StructByNameLax 2023-03-25 09:57:38 -05:00
Nazar Vovk
24c53259f8 Fix typo 2022-11-28 09:36:20 -06:00
Jack Christensen
2e9e2865f9 Added more docs and tests 2022-11-12 10:13:20 -06:00
Pavlo Golub
14be51536b implement RowToStructByName and RowToAddrOfStructByName 2022-11-12 09:39:54 -06:00
Baptiste Fontaine
3e825ec898 Fix RowToStructByPos on structs with multiple anonymous sub-structs
Fixes #1343
2022-10-22 10:02:32 -05:00
Jack Christensen
6e40968cfc CollectOneRow prefers PostgreSQL error over pgx.ErrorNoRows
fixes https://github.com/jackc/pgx/issues/1334
2022-10-22 08:44:06 -05:00
Jack Christensen
ee2622a8e6 RowToStructByPos supports embedded structs
https://github.com/jackc/pgx/issues/1273#issuecomment-1236966785
2022-09-06 18:32:10 -05:00
Jack Christensen
ae65a8007b Use higher pgconn.FieldDescription with string Name
Instead of using pgproto3.FieldDescription through pgconn and pgx. This
lets the lowest level pgproto3 still be as memory efficient as possible.

https://github.com/jackc/pgx/pull/1281
2022-08-20 10:04:18 -05:00
Jack Christensen
b6f5cbd15e Add Conn to Rows interface
https://github.com/jackc/pgx/issues/1191
2022-07-16 17:56:24 -05:00
Jack Christensen
78875bb95a Add tracing support
Replaces existing logging support. Package tracelog provides adapter for
old style logging.

https://github.com/jackc/pgx/issues/1061
2022-07-16 12:27:10 -05:00
Jack Christensen
759e47dba3 Merge branch 'master' into v5-dev 2022-07-12 07:26:00 -05:00
Jack Christensen
62f0347586 Add CollectOneRow 2022-07-09 16:59:29 -05:00
Jack Christensen
90c2dc6f68 Rename ForEachScannedRow to ForEachRow 2022-07-09 16:47:28 -05:00
Jack Christensen
da192291f7 Add CollectRows and RowTo* functions
Collect functionality was originally developed in pgxutil
2022-07-09 16:39:42 -05:00
Jack Christensen
e7aa76ccf9 SendBatch now uses pipeline mode to prepare and describe statements
Previously, a batch with 10 unique parameterized statements executed
100 times would entail 11 network round trips. 1 for each prepare /
describe and 1 for executing them all. Now pipeline mode is used to
prepare / describe all statements in a single network round trip. So it
would only take 2 round trips.
2022-07-09 09:32:36 -05:00
Jack Christensen
76946fb5a3 Replace QueryFunc with ForEachScannedRow 2022-07-07 20:29:04 -05:00
Jack Christensen
1168b375e4 Expose pgx functionality for manual integration with pgconn
This is primarily useful for using pipeline mode.
2022-07-04 13:29:49 -05:00
Stepan Rabotkin
bfb19cd4f6 feat: add time duration to error query and copy 2022-05-12 19:05:08 -05:00
Jack Christensen
c1495aace0 Add RowScanner interface 2022-04-30 12:49:12 -05:00
Jack Christensen
a89a400b69 Fix documentation for Rows.RawValues and test new behavior 2022-04-30 08:27:57 -05:00
Jack Christensen
f14fb3d692 Replace interface{} with any 2022-04-09 09:12:55 -05:00
Jack Christensen
8e341e20f3 Remove ConnConfig.BuildStatementCache 2022-03-12 09:23:40 -06:00
Jack Christensen
ffc5a692cb Detect unsafe pgtype.DriverBytes usage
Add test for unsafe usage and test for correct usage that ensures driver
memory is actually used.
2022-02-26 20:23:35 -06:00
Jack Christensen
95cbbfe441 Import pgproto3
Also copy in pgmock as an internal package.
2022-02-21 13:22:42 -06:00
Jack Christensen
1f2f239d09 Renamed pgtype.ConnInfo to pgtype.Map 2022-02-21 09:13:09 -06:00
Jack Christensen
bda10b2ec9 Rename pgtype.DataType to pgtype.Type 2022-02-21 09:01:48 -06:00
Jack Christensen
318018504a Merge branch 'master' into v5-dev 2022-02-07 11:22:01 -06:00
djsavvy
9eccdd6a81 Clarify that Values() and Scan() require Next() to have been called on the rows object 2022-02-05 20:06:01 -06:00
Jack Christensen
5ed95dcd1c Expose wrap functions on ConnInfo
- Remove rarely used ScanPlan.Scan arguments
- Plus other refactorings and fixes that fell out of this change.
- Plus rows Scan now handles checking for changed type.
2022-01-22 17:50:19 -06:00
Jack Christensen
2b395f3730 pgtype.DataType.Codec can never be nil 2022-01-22 12:21:16 -06:00
Jack Christensen
db95cee40c Remove pgtype.Value interface 2022-01-22 12:18:40 -06:00
Jack Christensen
4cf6dc9447 Remove BinaryEncoder and TextEncoder 2022-01-22 12:16:02 -06:00
Jack Christensen
f573cde09c Convert bytea to Codec 2022-01-08 18:33:08 -06:00
Jack Christensen
fcc9dcc960 Convert text to Codec
This also entailed updating and deleting types that depended on Text.
2022-01-08 13:13:26 -06:00
Jack Christensen
9fc8f9b3a8 Initial passing tests for main pgx package 2021-12-30 18:12:47 -06:00
Jack Christensen
72cc95e4dd Bump module version to v5 2021-12-11 13:29:03 -06:00
Jack Christensen
0e293b966c Finish import of pgconn 2021-12-04 14:06:57 -06:00
Jack Christensen
7e13db4538 Finish import of pgtype repo
Fix some tests that broke by merging repos
Tweak readme wording
2021-12-04 13:45:57 -06:00
Jack Christensen
a49f4bb135 Use errors instead of golang.org/x/xerrors 2021-03-25 09:55:12 -04:00
Pau Sanchez
9b58ab2db8 Make ScanArgError fields public 2021-02-20 08:43:57 -06:00
Pau Sanchez
8ad672475a Make ScanArgError public to allow identification of offending column
fixes #931
2021-02-13 08:56:11 -06:00
Jack Christensen
9b0e57c4a9 Fix panic on query error with nil stmtcache
fixes #895
2020-12-19 10:17:41 -06:00
Ethan Pailes
1df45d758d fix stmtcache invalidation
This patch fixes jackc/pgx#841. The meat of the fix lives
in [a PR to the pgconn repo][1]. This change just checks
for errors after executing a prepared statement and informs
the underlying stmtcache about them so that it can properly
clean up. We don't try to get fancy with retries or anything
like that, just return the error and allow the application to handle it.

I had to make [some][1] [changes][2] to to the jackc/pgconn package as well
as this package.

Fixes #841

[1]: https://github.com/jackc/pgconn/pull/56
[2]: https://github.com/jackc/pgconn/pull/55
2020-11-12 08:15:13 -05:00
Jack Christensen
2ec377350b Update Rows.Scan documentation to reflect reality.
Previously, the Scan documentation stated that scanning into a []byte
will skip the decoding process and directly copy the raw bytes received
from PostgreSQL.

This has not been true for at least 2 months. It is also undesirable
behavior in some cases such as a binary formatted jsonb. In that case
the '1' prefix needs to be stripped to have valid JSON. If the raw
bytes are desired this can easily be accomplished by scanning into
pgtype.GenericBinary or using Rows.RawValues.

In light of the fact that the new behavior is superior, and that it has
been in place for a significant amount of time, I have decided to
document the new behavior rather than change back to the old behavior.
2020-09-05 11:26:19 -05:00
Jack Christensen
43ce317556 Plan scans even if destination is nil
fixes #810
2020-08-21 18:34:52 -05:00