postgres-nio icon indicating copy to clipboard operation
postgres-nio copied to clipboard

Text format support for arrays

Open Yourney opened this issue 5 years ago • 1 comments

create a table:

CREATE TABLE media
(
    id bigserial NOT NULL PRIMARY KEY,
    tags text[]
);

now do:

let rows = try connection.simpleQuery("SELECT * FROM media WHERE id = '1'").wait()

then loop through the fields and callon the tags column: column.array(of: String.self)

The system dies here: Array b field did not equal zero. version: Vapor Postgres-NIO: 1.0.0-rc.1.2 file: PostgresNIO>Data>PostgresData+Array.swift line:78:

assert(b == 0, "Array b field did not equal zero")

The actual issue: Please implement support for arrays in simpleQuery.

Low prio requests:

  1. please rename 'b' to a more useful name
  2. please throw an error that is more clear than the b == 0 assertion.

Yourney avatar Mar 30 '20 17:03 Yourney

Note to test if TEXT[] = ["foo", NULL, "baz"] makes use of the b field.

tanner0101 avatar Mar 30 '20 17:03 tanner0101