haskell-beam / haskell-beam/beam

'TIMESTAMP WITH TIME ZONE' or 'TIMESTAMP WITHOUT TIME ZONE' required for LocalTime

Open
#530 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
635
Forks
193
PR merge metrics
No merged PRs in 30d

Description

I run into the following error when using `runInsertReturningList` with a Postgres database:

```
'TIMESTAMP WITH TIME ZONE' or 'TIMESTAMP WITHOUT TIME ZONE' required for LocalTime
```

which is an `error` thrown at https://github.com/haskell-beam/beam/blob/efd464b079755a781c2bb7a2fc030d6c141bbb8a/beam-postgres/Database/Beam/Postgres/Types.hs#L130.

The query printed by `runBeamPostgresDebug` is:

```sql
INSERT INTO "calculations"
(
"id",
"run__id",
"currency__symbol",
"numeraire__symbol",
"slippage",
"creation_time",
"start_time",
"duration_seconds"
)
VALUES
(
DEFAULT,
1,
'BTC',
'USD',
1.0e-2,
'2020-12-20 12:17:08.7135955',
NULL,
NULL
)
RETURNING "id",
"run__id",
"currency__symbol",
"numeraire__symbol",
"slippage",
"creation_time",
"start_time",
"duration_seconds"
```

and the schema for the table in question is:

```sql
CREATE TABLE calculations (
creation_time TIMESTAMP WITHOUT TIME ZONE NOT NULL
currency__symbol VARCHAR NOT NULL
duration_seconds DOUBLE PRECISION
id INT NOT NULL DEFAULT nextval('calculations___id___seq'::regclass)
numeraire__symbol VARCHAR NOT NULL
run__id NUMERIC(10) NOT NULL
slippage DOUBLE PRECISION NOT NULL
start_time TIMESTAMP WITHOUT TIME ZONE
);
```

I'm using `beam-core-0.9.0.0` and `beam-postgres-0.5.0.0`.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in beam-postgres/Database/Beam/Postgres/Types.hs around line 130 and reproduce the failure using runInsertReturningList with the PostgreSQL schema shown. Compare the timestamp column types with the returned LocalTime value and inspect the SQL from runBeamPostgresDebug. Done means the shown INSERT ... RETURNING case no longer raises the timestamp-type error.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell, postgresql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.