Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Support date without time

Open
#78 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
sqlite, swift
Domain
databases

Research direction

Start by reproducing the failure with the Todo.swift model and CreateTodo migration using a SQLite database and an ISO8601 date. Trace the SQLite date decoding path from the failing retrieval; done means fetching the todos succeeds and the Date field decodes without the reported error.

Written by the indexing model from the issue text.

Description

bug enhancement

Vapor 4 cannot decode dates.

Steps to reproduce
  1. Create an empty project using vapor-beta toolbox and using a SQLite database for testing purposes.

  2. Open Todo.swift file and add a field to store a date

Todo model file looks:

import Fluent
import Vapor

final class Todo: Model, Content {
    static let schema = "todos"
    
    @ID(key: .id)
    var id: UUID?

    @Field(key: "title")
    var title: String
    
    @Field(key: "date")
    var date: Date

    init() { }

    init(id: UUID? = nil, title: String, date: Date) {
        self.id = id
        self.title = title
        self.date = date
    }
}
  1. Configure the field on the migration file.
import Fluent

struct CreateTodo: Migration {
    func prepare(on database: Database) -> EventLoopFuture<Void> {
        return database.schema("todos")
            .id()
            .field("title", .string, .required)
            .field("date", .date, .required)
            .create()
    }

    func revert(on database: Database) -> EventLoopFuture<Void> {
        return database.schema("todos").delete()
    }
}
  1. Run the migrations.

  2. Create a new Todo with ISO8601 date.

  3. Try to get the todos. It fails.

Expected behavior

The list of todos is returned.

Actual behavior

[ ERROR ] invalid field: date type: Date error: Decoding error: Value of type 'Date' required for key ''.

Environment
  • Vapor Framework version: 4.0.0-rc.3.12
  • Fluent Framework version: 4.0.0-rc.1
  • Fluent-kit Framework version: 4.0.0-rc.1.16
  • Fluent-sqlite-driver Framework version: 4.0.0-rc.1.1
  • OS version: macOS 10.15.4
Dominant language
Swift
Stars
72
Forks
34
PR merge metrics
No merged PRs in 30d

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.

Similar issues

More Swift issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.