@@ -86,8 +86,49 @@ export class MySqlBigInt64<T extends ColumnBaseConfig<'bigint int64' | 'bigint u
8686 }
8787}
8888
89+ export class MySqlBigIntStringBuilder < TUnsigned extends boolean | undefined >
90+ extends MySqlColumnBuilderWithAutoIncrement < {
91+ name : string ;
92+ dataType : Equal < TUnsigned , true > extends true ? 'string uint64' : 'string int64' ;
93+ data : string ;
94+ driverParam : number | string ;
95+ } , { unsigned ?: boolean } >
96+ {
97+ static override readonly [ entityKind ] : string = 'MySqlBigIntStringBuilder' ;
98+
99+ constructor ( name : string , unsigned : boolean = false ) {
100+ super ( name , unsigned ? 'string uint64' : 'string int64' as any , 'MySqlBigIntString' ) ;
101+ this . config . unsigned = unsigned as TUnsigned ;
102+ }
103+
104+ /** @internal */
105+ override build ( table : MySqlTable ) {
106+ return new MySqlBigIntString (
107+ table ,
108+ this . config as any ,
109+ ) ;
110+ }
111+ }
112+
113+ export class MySqlBigIntString < T extends ColumnBaseConfig < 'string int64' | 'string uint64' > >
114+ extends MySqlColumnWithAutoIncrement < T , { unsigned : boolean } >
115+ {
116+ static override readonly [ entityKind ] : string = 'MySqlBigIntString' ;
117+
118+ getSQLType ( ) : string {
119+ return `bigint${ this . config . unsigned ? ' unsigned' : '' } ` ;
120+ }
121+
122+ override mapFromDriverValue ( value : number | string ) : string {
123+ if ( typeof value === 'string' ) {
124+ return value ;
125+ }
126+ return String ( value ) ;
127+ }
128+ }
129+
89130export interface MySqlBigIntConfig <
90- T extends 'number' | 'bigint' = 'number' | 'bigint' ,
131+ T extends 'number' | 'bigint' | 'string' = 'number' | 'bigint' | 'string ',
91132 TUnsigned extends boolean | undefined = boolean | undefined ,
92133> {
93134 mode : T ;
@@ -96,15 +137,22 @@ export interface MySqlBigIntConfig<
96137
97138export function bigint < TMode extends MySqlBigIntConfig [ 'mode' ] , TUnsigned extends boolean | undefined > (
98139 config : MySqlBigIntConfig < TMode , TUnsigned > ,
99- ) : TMode extends 'number' ? MySqlBigInt53Builder < TUnsigned > : MySqlBigInt64Builder < TUnsigned > ;
140+ ) : TMode extends 'bigint' ? MySqlBigInt64Builder < TUnsigned >
141+ : TMode extends 'string' ? MySqlBigIntStringBuilder < TUnsigned >
142+ : MySqlBigInt53Builder < TUnsigned > ;
100143export function bigint < TMode extends MySqlBigIntConfig [ 'mode' ] , TUnsigned extends boolean | undefined > (
101144 name : string ,
102145 config : MySqlBigIntConfig < TMode , TUnsigned > ,
103- ) : TMode extends 'number' ? MySqlBigInt53Builder < TUnsigned > : MySqlBigInt64Builder < TUnsigned > ;
104- export function bigint ( a ?: string | MySqlBigIntConfig , b ?: MySqlBigIntConfig ) {
146+ ) : TMode extends 'bigint' ? MySqlBigInt64Builder < TUnsigned >
147+ : TMode extends 'string' ? MySqlBigIntStringBuilder < TUnsigned >
148+ : MySqlBigInt53Builder < TUnsigned > ;
149+ export function bigint ( a : string | MySqlBigIntConfig , b ?: MySqlBigIntConfig ) {
105150 const { name, config } = getColumnNameAndConfig < MySqlBigIntConfig > ( a , b ) ;
106151 if ( config . mode === 'number' ) {
107152 return new MySqlBigInt53Builder ( name , config . unsigned ) ;
108153 }
154+ if ( config . mode === 'string' ) {
155+ return new MySqlBigIntStringBuilder ( name , config . unsigned ) ;
156+ }
109157 return new MySqlBigInt64Builder ( name , config . unsigned ) ;
110158}
0 commit comments