Add timestamp with timezone type

This commit is contained in:
Simon Binder 2024-01-17 17:31:55 +01:00
parent f84407a8cb
commit c4169f6f91
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
3 changed files with 17 additions and 0 deletions

View File

@ -1,3 +1,7 @@
## 1.1.0
- Add `PgTypes.timestampWithTimezone`.
## 1.0.0
- __Breaking__: The interval type now expects `Interval` types from postgres

View File

@ -49,6 +49,13 @@ final class PgTypes {
PgDate.fromDateTime,
);
/// The `timestamp with time zone` type in Postgres.
static const CustomSqlType<PgDateTime> timestampWithTimezone = DateType(
pg.Type.timestampWithTimezone,
'timestamp with time zone',
PgDateTime.new,
);
/// The `timestamp without time zone` type in Postgres.
static const CustomSqlType<PgDateTime> timestampNoTimezone = DateType(
pg.Type.timestampWithoutTimezone,

View File

@ -47,6 +47,12 @@ void main() {
group('json', () => testWith(PgTypes.json, {'foo': 'bar'}));
group('jsonb', () => testWith(PgTypes.jsonb, {'foo': 'bar'}));
group('point', () => testWith(PgTypes.point, pg.Point(90, -90)));
group(
'timestamp with timezone',
() => testWith(PgTypes.timestampWithTimezone,
PgDateTime(DateTime.utc(1996, 7, 8, 10, 0, 0))),
);
group(
'timestamp without timezone',
() => testWith(PgTypes.timestampNoTimezone,