volatiletech / sqlboiler

Generate a Go ORM tailored to your database schema.
BSD 3-Clause "New" or "Revised" License
6.56k stars 533 forks source link

Timestamps in sqlite #1356

Closed ShinyZero0 closed 4 months ago

ShinyZero0 commented 4 months ago

If you're having a generation problem please answer these questions before submitting your issue. Thanks!

What version of SQLBoiler are you using (sqlboiler --version)?

SQLBoiler v4.16.1

What is your database and version (eg. Postgresql 10)

sqlite 3.44.2 2023-11-24 11:41:44 ebead0e7230cd33bcec9f95d2183069565b9e709bf745c9b5db65cc0cbf92c0f

If this happened at generation time what was the full SQLBoiler command you used to generate your models? (if not applicable leave blank)

sqlboiler sqlite3

Please provide a relevant database schema so we can replicate your issue (Provided you are comfortable sharing this)

CREATE TABLE users (
    login TEXT NOT NULL PRIMARY KEY,
    name TEXT NOT NULL,
    password BLOB NOT NULL,
    admin BOOLEAN NOT NULL DEFAULT FALSE
);

CREATE TABLE articles (
    id INTEGER NOT NULL PRIMARY KEY,
    name TEXT NOT NULL,
    content TEXT NOT NULL,
    created_at INTEGER NOT NULL,
    updated_at INTEGER NOT NULL
);

Further information. What did you do, what did you expect?

Well, sqlite has no date or time datatypes. I hoped it'd handle integers as UNIX timestamps, but it generated me a struct with regular int64 fields. How do i work with timestamps in sqlite?

stephenafamo commented 4 months ago

You would have to configure a type replacement.

https://github.com/volatiletech/sqlboiler?tab=readme-ov-file#types