@@ -16,7 +16,7 @@ function Driver(config, connection, opts) {
1616
1717 var escapes = {
1818 escape : escape ,
19- escapeId : escapeId
19+ escapeId : this . escapeId . bind ( this )
2020 } ;
2121
2222 this . QuerySelect = new ( require ( "../../sql/Select" ) ) ( escapes ) ;
@@ -25,6 +25,10 @@ function Driver(config, connection, opts) {
2525 this . QueryRemove = new ( require ( "../../sql/Remove" ) ) ( escapes ) ;
2626}
2727
28+ Driver . prototype . sync = function ( opts , cb ) {
29+ return require ( "../DDL/sqlite" ) . sync ( this , opts , cb ) ;
30+ } ;
31+
2832Driver . prototype . on = function ( ev , cb ) {
2933 if ( ev == "error" ) {
3034 this . db . on ( "error" , cb ) ;
@@ -132,14 +136,22 @@ Driver.prototype.remove = function (table, conditions, cb) {
132136} ;
133137
134138Driver . prototype . clear = function ( table , cb ) {
135- var query = "DELETE FROM " + escapeId ( table ) ;
139+ var query = "DELETE FROM " + this . escapeId ( table ) ;
136140
137141 if ( this . opts . debug ) {
138142 require ( "../Debug" ) . sql ( 'sqlite' , query ) ;
139143 }
140144 this . db . all ( query , cb ) ;
141145} ;
142146
147+ Driver . prototype . escapeId = function ( id ) {
148+ var m = id . match ( / ^ ( .+ ) \. \* $ / ) ;
149+ if ( m ) {
150+ return '`' + m [ 1 ] . replace ( / \` / g, '``' ) + '`.*' ;
151+ }
152+ return '`' + id . replace ( / \` / g, '``' ) . replace ( / \. / g, '`.`' ) + '`' ;
153+ } ;
154+
143155function escape ( value ) {
144156 if ( Array . isArray ( value ) ) {
145157 return "(" + value . map ( escape ) + ")" ;
@@ -151,11 +163,3 @@ function escape(value) {
151163
152164 return "'" + value . replace ( / \' / g, "''" ) + "'" ;
153165}
154-
155- function escapeId ( id ) {
156- var m = id . match ( / ^ ( .+ ) \. \* $ / ) ;
157- if ( m ) {
158- return '`' + m [ 1 ] . replace ( / \` / g, '``' ) + '`.*' ;
159- }
160- return '`' + id . replace ( / \` / g, '``' ) . replace ( / \. / g, '`.`' ) + '`' ;
161- }
0 commit comments