@@ -7,20 +7,15 @@ import {
77import { SqlConnection } from './sql-base' ;
88import { Query } from '../query' ;
99import { QueryType } from '../query-params' ;
10- import {
11- Constraint ,
12- Database ,
13- Table ,
14- TableColumn ,
15- TableColumnDefinition ,
16- } from './../models/database' ;
10+ import { Constraint , Database , Table , TableColumn } from './../models/database' ;
1711import { MySQLDialect } from './../query-builder/dialects/mysql' ;
1812import {
1913 createErrorResult ,
20- transformArrayBasedResult ,
14+ transformFromSdkTransform ,
2115} from './../utils/transformer' ;
2216import { QueryResult } from '.' ;
2317import { ColumnDataType } from '../query-builder' ;
18+ import { transformMySQLResult } from '@outerbase/sdk-transform' ;
2419
2520interface MySQLSchemaResult {
2621 SCHEMA_NAME : string ;
@@ -127,10 +122,10 @@ export function buildMySQLDatabaseSchmea({
127122
128123 columnLookup [
129124 column . TABLE_SCHEMA +
130- '.' +
131- column . TABLE_NAME +
132- '.' +
133- column . COLUMN_NAME
125+ '.' +
126+ column . TABLE_NAME +
127+ '.' +
128+ column . COLUMN_NAME
134129 ] = columnObject ;
135130
136131 table . columns . push ( columnObject ) ;
@@ -156,10 +151,10 @@ export function buildMySQLDatabaseSchmea({
156151
157152 constraintLookup [
158153 constraint . TABLE_SCHEMA +
159- '.' +
160- constraint . TABLE_NAME +
161- '.' +
162- constraint . CONSTRAINT_NAME
154+ '.' +
155+ constraint . TABLE_NAME +
156+ '.' +
157+ constraint . CONSTRAINT_NAME
163158 ] = constraintObject ;
164159
165160 table . constraints . push ( constraintObject ) ;
@@ -169,22 +164,22 @@ export function buildMySQLDatabaseSchmea({
169164 for ( const constraintColumn of constraintColumnsList ) {
170165 const constraint =
171166 constraintLookup [
172- constraintColumn . TABLE_SCHEMA +
173- '.' +
174- constraintColumn . TABLE_NAME +
175- '.' +
176- constraintColumn . CONSTRAINT_NAME
167+ constraintColumn . TABLE_SCHEMA +
168+ '.' +
169+ constraintColumn . TABLE_NAME +
170+ '.' +
171+ constraintColumn . CONSTRAINT_NAME
177172 ] ;
178173
179174 if ( ! constraint ) continue ;
180175
181176 const currentColumn =
182177 columnLookup [
183- constraintColumn . TABLE_SCHEMA +
184- '.' +
185- constraintColumn . TABLE_NAME +
186- '.' +
187- constraintColumn . COLUMN_NAME
178+ constraintColumn . TABLE_SCHEMA +
179+ '.' +
180+ constraintColumn . TABLE_NAME +
181+ '.' +
182+ constraintColumn . COLUMN_NAME
188183 ] ;
189184 if ( currentColumn && constraintColumn . REFERENCED_COLUMN_NAME ) {
190185 currentColumn . definition . references = {
@@ -254,18 +249,11 @@ export class MySQLConnection extends SqlConnection {
254249 ) ;
255250
256251 if ( error ) {
257- return createErrorResult ( error . message ) as QueryResult < T > ;
252+ return createErrorResult < T > ( error . message ) ;
258253 } else {
259- return transformArrayBasedResult (
260- fields ,
261- ( header ) => {
262- return {
263- name : header . name ,
264- tableName : header . table ,
265- } ;
266- } ,
267- rows as unknown [ ] [ ]
268- ) as QueryResult < T > ;
254+ return transformFromSdkTransform (
255+ transformMySQLResult ( [ rows , fields ] )
256+ ) ;
269257 }
270258 } catch {
271259 return createErrorResult ( 'Unknown error' ) as QueryResult < T > ;
@@ -377,7 +365,7 @@ export class MySQLConnection extends SqlConnection {
377365 ) ;
378366 }
379367
380- async connect ( ) : Promise < any > { }
368+ async connect ( ) : Promise < any > { }
381369 async disconnect ( ) : Promise < any > {
382370 this . conn . destroy ( ) ;
383371 }
0 commit comments