vapor / postgres-nio

🐘 Non-blocking, event-driven Swift client for PostgreSQL.
https://api.vapor.codes/postgresnio/documentation/postgresnio/
MIT License
327 stars 75 forks source link

Text format support for arrays #92

Open Yourney opened 4 years ago

Yourney commented 4 years ago

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.

tanner0101 commented 4 years ago

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