@@ -570,7 +570,7 @@ class SqliteAdapter {
570570 return ( async function ( ) {
571571 // prepare to rename existing table and create a new one
572572 const renamed = '__' + migration . appliesTo + '_' + new Date ( ) . getTime ( ) . toString ( ) + '__' ;
573- const formatter = new SqliteFormatter ( ) ;
573+ const formatter = self . getFormatter ( ) ;
574574 const renameTable = formatter . escapeName ( renamed ) ;
575575 const table = formatter . escapeName ( migration . appliesTo ) ;
576576 const existingFields = await self . table ( migration . appliesTo ) . columnsAsync ( ) ;
@@ -613,7 +613,7 @@ class SqliteAdapter {
613613 } ) ;
614614 }
615615 else {
616- const formatter = new SqliteFormatter ( ) ;
616+ const formatter = self . getFormatter ( ) ;
617617 migration . add . forEach ( function ( x ) {
618618 //search for columns
619619 expressions . push ( sprintf ( 'ALTER TABLE %s ADD COLUMN %s %s' , formatter . escapeName ( migration . appliesTo ) , formatter . escapeName ( x . name ) , self . formatType ( x ) ) ) ;
@@ -956,8 +956,8 @@ class SqliteAdapter {
956956 return callback ( ) ;
957957 }
958958 // generate SQL statement
959- const formatter = new SqliteFormatter ( ) ;
960- const escapedTable = new SqliteFormatter ( ) . escapeName ( name ) ;
959+ const formatter = self . getFormatter ( ) ;
960+ const escapedTable = formatter . escapeName ( name ) ;
961961 const sql = fields . map ( ( field ) => {
962962 const escapedField = formatter . escapeName ( field . name ) ;
963963 return sprintf ( 'ALTER TABLE %s ADD COLUMN %s %s' , escapedTable , escapedField , self . formatType ( field ) ) ;
@@ -1065,7 +1065,7 @@ class SqliteAdapter {
10651065 }
10661066 try {
10671067 let sql = sprintf ( 'CREATE VIEW `%s` AS ' , name ) ;
1068- const formatter = new SqliteFormatter ( ) ;
1068+ const formatter = self . getFormatter ( ) ;
10691069 sql += formatter . format ( q ) ;
10701070 self . execute ( sql , undefined , tr ) ;
10711071 }
@@ -1138,7 +1138,7 @@ class SqliteAdapter {
11381138 }
11391139 else {
11401140 //format query expression or any object that may act as query expression
1141- const formatter = new SqliteFormatter ( ) ;
1141+ const formatter = this . getFormatter ( ) ;
11421142 sql = formatter . format ( query ) ;
11431143 }
11441144 //validate sql statement
@@ -1305,7 +1305,7 @@ class SqliteAdapter {
13051305 }
13061306
13071307 indexes ( table ) {
1308- const self = this , formatter = new SqliteFormatter ( ) ;
1308+ const self = this , formatter = this . getFormatter ( ) ;
13091309 return {
13101310 list : function ( callback ) {
13111311 const this1 = this ;
@@ -1432,7 +1432,7 @@ class SqliteAdapter {
14321432 if ( ! exists ) {
14331433 return callback ( ) ;
14341434 }
1435- const formatter = new SqliteFormatter ( ) ;
1435+ const formatter = self . getFormatter ( ) ;
14361436 self . execute ( sprintf ( 'DROP INDEX %s' , formatter . escapeName ( name ) ) , [ ] , callback ) ;
14371437 } ) ;
14381438 } ,
@@ -1448,6 +1448,10 @@ class SqliteAdapter {
14481448 }
14491449 } ;
14501450 }
1451+
1452+ getFormatter ( ) {
1453+ return new SqliteFormatter ( ) ;
1454+ }
14511455}
14521456
14531457export {
0 commit comments