Comments (6)
@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.
@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.
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.
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.
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.
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)
- client:generate error P1017 HOT 6
- error: "Field is already defined on model" when field has same name as table HOT 2
- Suggestion: better error message when electrifying table with missing primary key HOT 1
- Starting the electric sync service was confusing HOT 1
- Non-obvious connection string issue with generating client / better help needed HOT 2
- Weird documentation doing a React Native install
- PG_PROXY_URL not honored. Should be replaced with ELECTRIC_PROXY_URL HOT 2
- Prisma generator script not working in monorepos HOT 1
- when I exec npx electric-sql generate ,the console is blocking.
- Uncaught (in promise) TypeError: globalThis.uuid is not a function HOT 18
- Unable to pull docker image in supabase example HOT 2
- connecting to db in docker container fails on windows HOT 11
- Cannot read properties of undefined (reading 'numTables') thrown during electrification of Capacitor adapter HOT 2
- Insufficient privileges while connecting to supabase HOT 7
- Docker compose separator conflict HOT 4
- "iat" claim is invalid unless I add timeout HOT 2
- Electric mesh allows connection only in `replication=database` mode HOT 2
- Altering a table with existing data to add a jsonb column results in zod parse errors HOT 3
- Feature request: Dart support HOT 3
- query including referenced table errors sometimes HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from electric.