File tree Expand file tree Collapse file tree 4 files changed +19
-2993
lines changed
Expand file tree Collapse file tree 4 files changed +19
-2993
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " kysely-data-api " : major
3+ ---
4+
5+ fix(driver): return Object for JSON columns and imply UTC for timestampz
Original file line number Diff line number Diff line change 1111 "license" : " MIT" ,
1212 "scripts" : {
1313 "clean" : " rm -rf dist && rm -rf test/dist" ,
14- "release" : " yarn build && yarn changeset publish" ,
15- "build" : " yarn clean && yarn build:esm && yarn build:cjs && ./module-fixup.sh" ,
14+ "release" : " pnpm build && pnpm changeset publish" ,
15+ "build" : " pnpm clean && pnpm build:esm && pnpm build:cjs && ./module-fixup.sh" ,
1616 "test" : " AWS_SDK_LOAD_CONFIG=1 vitest" ,
1717 "build:esm" : " tsc -p tsconfig-esm.json" ,
1818 "build:cjs" : " tsc -p tsconfig-cjs.json"
Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ class DataApiConnection implements DatabaseConnection {
112112 . map ( ( rec ) =>
113113 Object . fromEntries (
114114 rec . map ( ( val , i ) => {
115- const { label, name, typeName } = r . columnMetadata ! [ i ]
115+ const { label, name, typeName } = r . columnMetadata ! [ i ] ;
116116 const key = label || name ;
117117 let value = val . isNull
118118 ? null
@@ -124,20 +124,23 @@ class DataApiConnection implements DatabaseConnection {
124124 val . blobValue ??
125125 null ; // FIXME: should throw an error here?
126126
127- if ( typeof ( value ) === 'string' && typeName && [ "timestamp" , "timestamptz" , "date" ] . includes (
128- typeName . toLocaleLowerCase ( )
129- ) ) {
130- value = new Date ( value ) ;
127+ if ( typeof value === "string" && typeName ) {
128+ const typeNameSafe = typeName . toLocaleLowerCase ( ) ;
129+ if ( [ "timestamp" , "date" ] . includes ( typeNameSafe ) ) {
130+ value = new Date ( value ) ;
131+ } else if ( typeNameSafe === "timestamptz" ) {
132+ value = new Date ( `${ value } Z` ) ;
133+ } else if ( [ "json" , "jsonb" ] . includes ( typeNameSafe ) ) {
134+ value = JSON . parse ( value ) ;
135+ }
131136 }
132137
133138 return [ key , value ] ;
134139 } )
135140 )
136141 ) ;
137- const result : QueryResult < O > = {
138- rows : rows || [ ] ,
139- } ;
140- return result ;
142+
143+ return { rows : rows ?? [ ] } ;
141144 }
142145
143146 async * streamQuery < O > (
You can’t perform that action at this time.
0 commit comments