File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2626 "esbuild" : " ^0.13.6" ,
2727 "esbuild-runner" : " ^2.2.1" ,
2828 "jest" : " ^27.2.5" ,
29- "kysely" : " ^0.16.5 " ,
29+ "kysely" : " ^0.16.6 " ,
3030 "perf_hooks" : " ^0.0.1"
3131 },
3232 "peerDependencies" : {
3333 "aws-sdk" : " ^2.1008.0" ,
34- "kysely" : " ^0.7.7 "
34+ "kysely" : " ^0.16.6 "
3535 },
3636 "files" : [
3737 " dist"
Original file line number Diff line number Diff line change 1- import { Driver , PostgresAdapter } from "kysely" ;
2- import { Kysely } from "kysely" ;
3- import { QueryCompiler } from "kysely" ;
4- import { Dialect } from "kysely" ;
5- import { DatabaseIntrospector } from "kysely" ;
6- import { PostgresIntrospector } from "kysely" ;
1+ import {
2+ Driver ,
3+ MysqlAdapter ,
4+ MysqlIntrospector ,
5+ PostgresAdapter ,
6+ Kysely ,
7+ QueryCompiler ,
8+ Dialect ,
9+ DatabaseIntrospector ,
10+ PostgresIntrospector ,
11+ } from "kysely" ;
712import { DataApiDriver , DataApiDriverConfig } from "./data-api-driver" ;
813import {
914 PostgresDataApiQueryCompiler ,
@@ -23,7 +28,10 @@ export class DataApiDialect implements Dialect {
2328 }
2429
2530 createAdapter ( ) {
26- return new PostgresAdapter ( ) ;
31+ if ( this . #config. mode === "postgres" ) return new PostgresAdapter ( ) ;
32+ if ( this . #config. mode === "mysql" ) return new MysqlAdapter ( ) ;
33+
34+ throw new Error ( "Unknown mode " + this . #config. mode ) ;
2735 }
2836
2937 createDriver ( ) : Driver {
@@ -39,6 +47,9 @@ export class DataApiDialect implements Dialect {
3947 }
4048
4149 createIntrospector ( db : Kysely < any > ) : DatabaseIntrospector {
42- return new PostgresIntrospector ( db ) ;
50+ if ( this . #config. mode === "postgres" ) return new PostgresIntrospector ( db ) ;
51+ if ( this . #config. mode === "mysql" ) return new MysqlIntrospector ( db ) ;
52+
53+ throw new Error ( "Unknown mode " + this . #config. mode ) ;
4354 }
4455}
Original file line number Diff line number Diff line change @@ -120,14 +120,14 @@ class DataApiConnection implements DatabaseConnection {
120120 Object . fromEntries (
121121 rec . map ( ( val , i ) => [
122122 r . columnMetadata ! [ i ] . name ,
123- val . stringValue ||
124- val . blobValue ||
125- val . longValue ||
126- val . arrayValue ||
127- val . doubleValue ||
123+ val . stringValue ??
124+ val . blobValue ??
125+ val . longValue ??
126+ val . arrayValue ??
127+ val . doubleValue ??
128128 ( val . isNull ? null : val . booleanValue ) ,
129129 ] )
130- ) as O
130+ ) as unknown as O
131131 ) ;
132132 const result : QueryResult < O > = {
133133 rows : rows || [ ] ,
Original file line number Diff line number Diff line change @@ -27,17 +27,22 @@ export class MysqlDataApiQueryCompiler extends MysqlQueryCompiler {
2727 }
2828
2929 protected override getCurrentParameterPlaceholder ( ) {
30- return ":" + this . addParameter ;
30+ return ":" + this . numParameters ;
3131 }
3232}
3333
3434function serialize ( value : any ) : Field {
3535 if ( value == null ) return { isNull : true } ;
3636 switch ( typeof value ) {
3737 case "number" :
38- return {
39- longValue : value ,
40- } ;
38+ if ( Number . isInteger ( value ) )
39+ return {
40+ longValue : value ,
41+ } ;
42+ else
43+ return {
44+ doubleValue : value ,
45+ } ;
4146 case "bigint" :
4247 return {
4348 doubleValue : Number ( value ) ,
@@ -50,6 +55,12 @@ function serialize(value: any): Field {
5055 return {
5156 booleanValue : value ,
5257 } ;
58+ case "object" :
59+ if ( Buffer . isBuffer ( value ) )
60+ return {
61+ blobValue : value ,
62+ } ;
63+ else break ;
5364 }
5465
5566 throw "wtf" ;
You can’t perform that action at this time.
0 commit comments