Commit Graph

16 Commits (ccb207cba5b4dd520b9cc40994eeb161ce140737)

Author SHA1 Message Date
Jack Christensen c16a4f7d6a Revert "Temporarily delete tests and pgxtype to break recursive dependency with pgx"
This reverts commit 32e20a6031.
2021-07-24 10:40:30 -05:00
Jack Christensen 32e20a6031 Temporarily delete tests and pgxtype to break recursive dependency with pgx 2021-07-24 10:16:00 -05:00
Jack Christensen af0ca3a39b Fix simple protocol empty array and original recursive empty array issue
Original issue https://github.com/jackc/pgtype/issues/68

This crash occurred in the recursive assignment system used to support
multidimensional arrays.

This was fixed in 9639a69d45. However,
that fix incorrectly used nil instead of an empty slice.

In hindsight, it appears the fundamental error is that an assignment to
a slice of a type that is not specified is handled with the recursive /
reflection path. Or another way of looking at it is as an unexpected
feature where []T can now be scanned if individual elements are
assignable to T even if []T is not specifically handled.

But this new reflection / recursive path did not handle empty arrays.

This fix handles the reflection path for an empty slice by allocating an
empty slice.
2020-10-31 17:12:16 -05:00
Simo Haasanen 9639a69d45 Adds checks for zero length arrays.
Assigning values from nil or zero length elements or dimensions now return immediately as there are no values to assign.
2020-10-20 19:52:05 +01:00
Simo Haasanen 449a8a4f8e Add multidimensional array and slice support.
Adds array support - previously only slices were supported.
Adds new test cases for multidimensional arrays and slices.
All previous test cases are unmodified and passed (fully backwards compatible).
Removes hard-coded type conversions for arrays, instead now relies on the type support of the array element's type conversion support.
Less maintenance for arrays, new type conversions are automatically supported when array's element gains new type support.
Simplifies typed_array_gen.sh generator script by removing the hard-coded single-dimensional types for arrays.
Only typed_array.go.erb and typed_array_gen.sh have been changed + 1 new auxiliary function in array.go file + additional tests in test files for each array. Other changes are from generated code.
2020-08-07 13:10:32 +01:00
Jack Christensen ef5f8b54af Update dependencies 2020-03-30 11:30:37 -05:00
Jack Christensen ab885b375b OID type should only be used for scanning and encoding values
It was a mistake to use it in other contexts. This made interop
difficult between pacakges that depended on pgtype such as pgx and
packages that did not like pgconn and pgproto3. In particular this was
awkward for prepared statements.

Because pgx depends on pgtype and the tests for pgtype depend on pgx
this change will require a couple back and forth commits to get the
go.mod dependecies correct.
2019-08-24 13:49:12 -05:00
Jack Christensen 4ed0de4755 Splitting pgtype into own repo 2019-04-20 19:14:08 -05:00
Jack Christensen 8502a12ac7 Fix go modules
Wow. This is fun. Sure is easy to get modules wrong when upgrading a v2+
project.
2019-04-20 17:41:08 -05:00
Jack Christensen 6161728ff9 Prepare takes context
Also remove PrepareEx. It's primary usage was for context. Supplying
parameter OIDs is unnecessary when you can type cast in the query SQL.
If it does become necessary or desirable to add options back it can be
added in a backwards compatible way by adding a varargs as last
argument.
2019-04-20 11:47:16 -05:00
Jack Christensen bd85fe870d Hard code standard PostgreSQL types
Instead of needing to instrospect the database on connection preload the
standard OID / type map. Types from extensions (like hstore) and custom
types can be registered by the application developer. Otherwise, they
will be treated as strings.
2019-04-13 16:45:52 -05:00
Jack Christensen fcbd9e93fa Initial pass at fixing pgtype tests
Many still failing, but at least it compiles now.
2019-04-12 16:58:42 -05:00
ferhat elmas 645e646183 Run gofmt with simplify flag 2017-12-21 23:45:26 +01:00
Jack Christensen a3e05ea29f Fix TestHstoreArrayTranscode 2017-05-20 08:42:39 -05:00
Jack Christensen e380de7cd1 Finish extraction of pgtype test helpers 2017-04-14 12:38:33 -05:00
Jack Christensen df8f8e17cf Add pgtype.HstoreArray
This required restructuring array types to lookup oid of element instead of
hard-coding it due to hstore having a variable oid.
2017-03-18 12:40:54 -05:00