This completes the port from the old native bindings to the new node-pg-native bindings!
Time to build in support for older versions of postgres & start the pull request process.
Postgres generally does not emit a SELECT tag after a SELECT query, but
it does emit that tag after a CREATE TABLE x AS SELECT query.
Example:
postgres=# create table t as select 1;
SELECT 1
End statements with semicolons, to be consistent with the surrounding
code.
Added a new unit test to ensure environment variables are honored when
parsing a
connection string.
Added a TODO to cleanup a test that emits messages using console.log().
Correct a query's syntax. Looks like a good thing to do even though the
syntax
doesn't matter in mocked out tests.
Removed a test that tests for SELECT tags; AFAIK, SELECT commands don't
emit a
tag.
Improve the code and clarity of unit tests in escape-tests.js. And
removed the related integration tests since it has been demonstrated in
the unit tests that a connection is not needed for escaping the literals
and identifiers.
a fix was provided in 5079c1e0c41f431ac2e02c40ebd875d8fbb34004;
test is modeled on query-error-handling-tests.js;
test both kill query and disconnection on prepared statement execution;
make connection error string message consistent between native and non-native;
disable test server-side kill for native as it hangs;
sync can cause error to be emitted so we catch that;
we also move _ending state before _send is called.
Attempt to call a `toPostgres` method on objects passed as query values
before converting them to JSON. This allows custom types to convert
themselves to the appropriate PostgreSQL literal.
This strategy is fully backwards-compatible and uses the same pattern as
the `toJSON` override.
`arrayString` duplicated too much of `prepareValue`'s logic, and so
didn't receive bugfixes for handling dates with timestamps. Defer to
`prepareValue` whenever possible.
This change enforces double-quote escaping of all array elements,
regardless of whether escaping is necessary. This has the side-effect of
properly escaping JSON arrays.