Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

#18 Updates timestamps to improve consistency between PostgREST and realtime

Paul Copplestone035b2d43040b
diff --git a/libraries/supabase-js/package.json b/libraries/supabase-js/package.json
index 03ae925bce8..931442a52d0 100644
--- a/libraries/supabase-js/package.json
+++ b/libraries/supabase-js/package.json
@@ -1,6 +1,6 @@
{
"name": "@supabase/supabase-js",
- "version": "0.1.16",
+ "version": "0.1.17",
"description": "Supabase Realtime API",
"main": "./lib/index.js",
"scripts": {
diff --git a/libraries/supabase-js/src/utils/ChangeMapper.js b/libraries/supabase-js/src/utils/ChangeMapper.js
index f49253abead..3dc8bce1195 100644
--- a/libraries/supabase-js/src/utils/ChangeMapper.js
+++ b/libraries/supabase-js/src/utils/ChangeMapper.js
@@ -106,7 +106,7 @@ export const convertChangeData = (columns, records, options = {}) => {
case 'time':
return noop(stringValue) // To allow users to cast it based on Timezone
case 'timestamp':
- return noop(stringValue) // To allow users to cast it based on Timezone
+ return toTimestampString(stringValue) // Format to be consistent with PostgREST
case 'timestamptz':
return noop(stringValue) // To allow users to cast it based on Timezone
case 'timetz':
@@ -160,4 +160,18 @@ export const convertChangeData = (columns, records, options = {}) => {
}
const toJson = stringValue => {
return JSON.parse(stringValue)
+ }
+
+ /**
+ * Fixes timestamp to be ISO-8601. Swaps the space between the date and time for a 'T'
+ * See https://github.com/supabase/supabase/issues/18
+ * @returns {string}
+ *
+ * @example
+ * toTimestampString('2019-09-10 00:00:00')
+ * //=>
+ * '2019-09-10T00:00:00'
+ */
+ const toTimestampString = stringValue => {
+ return stringValue.replace(' ', 'T')
}
\ No newline at end of file