typelevel / typelevel/doobie

specs2 null check fails with PostgreSQL views

Open
#613 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

JDBC driver issue
Dominant language
Scala
Stars
2.2k
Forks
379
Avg merge
14m
Merged PRs (30d)
8

Description

The specs2 unit tests falsely expects all columns to be nullable if the query uses a view. The root cause seems to be incorrect metadata from PostgreSQL. PostgreSQL reports all view columns as nullable even for trivial views:

create table test (id int not null);
create view test_view as select * from test;

\d test
Table "public.test"
 Column |  Type   | Modifiers 
--------+---------+-----------
 id     | integer | not null

viskar=> \d test_view
View "public.test_view"
 Column |  Type   | Modifiers 
--------+---------+-----------
 id     | integer |

Related StackOverflow question: https://stackoverflow.com/questions/17301323/why-are-my-views-columns-nullable

Maybe a simple solution would be to be able to manually disable the null check for a query but keeping the other type mapping validation features enabled?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the specs2 unit tests and the nullability metadata handling for PostgreSQL views, then reproduce the shown table and view definitions. Confirm how PostgreSQL reports view columns and define done as avoiding a false nullability failure while preserving the other type-mapping validations.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, scala
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.