nikita-volkov / hasql

The fastest PostgreSQL libpq-based driver for Haskell
http://hackage.haskell.org/package/hasql
MIT License
519 stars 55 forks source link

QueryError: add displayException #158

Closed domenkozar closed 10 months ago

domenkozar commented 10 months ago

When doing initial schema query, that can span for hundreds of lines of SQL.

Currently the SQL is shown as a one line and an error with a character position.

This improves the formatting into:

QueryError!

  Query:
CREATE EXTENSION IF NOT EXISTS pgcrypto;

CREATE OR REPLACE FUNCTION generate_ulid() RETURNS uuid
    AS $$
        SELECT (lpad(to_hex(floor(extract(epoch FROM clock_timestamp()) * 1000)::bigint), 12, '0') || encode(gen_random_bytes(10), 'hex'))::uuid;
    $$ LANGUAGE SQL;

CREATE TABLE account (
  id BIGINT NOT NULL DEFAULT 
);
^ syntax error at or near ")"

  Params: []
  Error: Server error 42601