Giter Site home page Giter Site logo

Comments (6)

alco avatar alco commented on May 17, 2024 1

@js2702 Yes, we're adding support for date, time, timestamp, and timestamptz types to DAL. They will all be stored as TEXT in SQLite and converted to/from the JS Date object.

Example values in SQLite:

  • date: 2023-08-24
  • time: 17:48:51.122
  • timestamp: 2023-08-24 17:48:52
  • timestamptz: 2023-08-24 17:48.53.000009Z

from electric.

alco avatar alco commented on May 17, 2024 1

@js2702 In Postgres, timestamp is defined as represnting local time without any reference time zone attached to it. We're treating it as such in DAL too. So when DAL builds a new Date object from a timestamp value, it takes the timestamp and passes it verbatim to Date's constructor:

> d = new Date("2023-09-20 11:06:00")
Date Wed Sep 20 2023 11:06:00 GMT+0300 (Eastern European Summer Time)

> d.toString()
"Wed Sep 20 2023 11:06:00 GMT+0300 (Eastern European Summer Time)" 

That's the date in my time zone. If you initialize a Date object using the same string, you'll get the same time of day but it will be in your time zone.

Internally, Date stores the time in UTC, so if I explicitly request a UTC-based string from it, the time of day will be different:

> d.toUTCString()
"Wed, 20 Sep 2023 08:06:00 GMT" 

We believe this behaviour is consistent with how timestamp works in Postgres. For an objective point in time that can be correctly interpreted in any time zone one should use the timestamptz type.

from electric.

js2702 avatar js2702 commented on May 17, 2024

I'm guessing one of the reasons is the timestamp data type in Postgresql. Are you planning to make the DAL client work with Date objects in Javascript? And convert them to text internally? We are having the same discussion for the Dart client. Ideally to prevent the user inserting a non date string into the sqlite.

from electric.

js2702 avatar js2702 commented on May 17, 2024

So when storing that timestamp, without the Z for UTC, would dates be treated always as UTC in the DAL? Or would this case be treated as local time?

from electric.

tyrauber avatar tyrauber commented on May 17, 2024

hey @kevin-dp, are you familiar with postgraphile? There is a lot of similarity between projects I think, specifically in regards to JWT and RLS usage in postgres. Postgraphile uses pg-introspection to do a sql introspection query that generates the graphql schema used in graphiql. Perhaps, electric-sql could do something similar?

from electric.

kevin-dp avatar kevin-dp commented on May 17, 2024

hey @kevin-dp, are you familiar with postgraphile? There is a lot of similarity between projects I think, specifically in regards to JWT and RLS usage in postgres. Postgraphile uses pg-introspection to do a sql introspection query that generates the graphql schema used in graphiql. Perhaps, electric-sql could do something similar?

Hi @tyrauber, just noticing your comment now. Interesting, will definitely flag it up for consideration. Thanks!

from electric.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.