Private Issues: Consistent Nullable Fields #453

Closed
opened 2026-03-09 16:25:56 +00:00 by nphilipp · 1 comment
Member

Storytime

As a Forgejo developer or community contributor,
I want that nullable DB fields are expressed in a consistent way,
to avoid that using different ways confuse me.

As a Forgejo contributor,
I want that pointers are used sparingly,
to reduce the risk of attempting to dereference nil pointers.

Acceptance Criteria

  • IssueId, PrivateIssueID style pairs of database fields use sql.NullInt64 types instead of pointers
  • Migration scripts are adapted accordingly
  • Unit and integration tests finish successfully

Background

I only now noticed that other tables with nullable fields use sql.Null* types instead of pointers to express that a field can be null (and won’t be set to 0 on insertion if unspecified like with the non-pointer type). Additional advantages are a) that these can’t be nil, preventing crashes when naïvely accessing NULL values, and b) these types allow to distinguish between the null-value of the type and a NULL in the table column.

# Storytime As a Forgejo developer or community contributor, I want that nullable DB fields are expressed in a consistent way, to avoid that using different ways confuse me. As a Forgejo contributor, I want that pointers are used sparingly, to reduce the risk of attempting to dereference `nil` pointers. # Acceptance Criteria - [x] `IssueId`, `PrivateIssueID` style pairs of database fields use `sql.NullInt64` types instead of pointers - [x] Migration scripts are adapted accordingly - [x] Unit and integration tests finish successfully # Background I only now noticed that other tables with nullable fields use `sql.Null*` types instead of pointers to express that a field can be null (and won’t be set to `0` on insertion if unspecified like with the non-pointer type). Additional advantages are a) that these can’t be `nil`, preventing crashes when naïvely accessing NULL values, and b) these types allow to distinguish between the null-value of the type and a NULL in the table column.
nphilipp added this to the Sprint 16 project 2026-03-09 16:25:56 +00:00
Author
Member

Fixed in my feature branch in “feat: Private Issues: Foundational changes”.

Fixed in [my feature branch](https://codeberg.org/nilsph/forgejo/src/branch/forgejo--private-issues) in “feat: Private Issues: Foundational changes”.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Blocks
Reference
forge/forge#453
No description provided.