tursodatabase / libsql-client-go

Go client API for libSQL
MIT License
166 stars 23 forks source link

time.Time Support for ORM's #70

Closed lewisje1991 closed 10 months ago

lewisje1991 commented 11 months ago

Description

When not using strict schema mode columns can be created with DateTime as a valid type in Sqlite. ORM's and schema generation tools like gorm & sqlc map this DateTime to golang's time.Time type. This type is then provided directly to libsql to build the query.

But there is no support for mapping this type.

Example schema

CREATE TABLE IF NOT EXISTS bookmarks (
  description VARCHAR(255) NOT NULL,
  created_at DATETIME NOT NULL,
  updated_at DATETIME NOT NULL
);

Questions?

  1. Should the recommendation be that strict mode is used on table creation to stop ORM's from mapping to unsupported type?
  2. Should libsql support more primitive golang types and convert them to sqlite base types?
haaawk commented 10 months ago

@lewisje1991 here's a potential fix https://github.com/libsql/libsql-client-go/pull/77 Please let me know if that fixes the problem for you.