14 Commits

Author SHA1 Message Date
Jack Christensen
dd160540c4 Use Go 1.13 errors instead of xerrors 2021-03-25 09:08:27 -04:00
Jack Christensen
00d516f5c4 Fix panic on assigning empty array to non-slice or array
See https://github.com/jackc/pgx/issues/881
2020-11-27 11:56:21 -06:00
Jack Christensen
740b3a5115 Fix: Text array parsing disambiguates NULL and "NULL".
This solution is a little awkward, but it avoids breaking backwards
compatibility.

fixes #78
2020-11-07 07:41:49 -06: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 9639a69d451f55456f598c1aa8b93053f8df3088. 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
Jack Christensen
9d7fc8e63a AssignTo pointer to pointer to slice and named types
fixes #69
2020-10-24 09:21:42 -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
Jack Christensen
9da6afcad7 Fix selecting empty array
Failing test was in pgx: TestReadingValueAfterEmptyArray
2020-09-05 10:56:22 -05:00
Jack Christensen
79b05217d1 Fix JSONBArray to have elements of JSONB 2020-09-04 18:41:34 -05:00
Simo Haasanen
ec14212d30 Add comments to explain the use of reflection after type assertion.
Removes one local variable, which is used twice only in an error.
2020-08-09 09:17:40 +01:00
Simo Haasanen
b90570feb5 Restored more optimised array type conversions for a few select 1D-slice types.
Results of calls to the reflect lib are now stored as local variables for small performance gains.
2020-08-08 19:51:37 +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
66a0b33655 Rerun typed_array_gen.sh 2020-06-24 08:40:34 -05:00
tserakhau
44f45c6c62 Use erb for jsonb array generation 2020-06-21 14:21:16 +03:00
tserakhau
35d2873de1 Fix 490: Add jsonb arrays for pgx v4 2020-06-18 17:11:54 +03:00