@@ -147,10 +147,11 @@ class SqliteFormatter extends SqlFormatter {
147147 * @returns {string }
148148 */
149149 $substring ( p0 , pos , length ) {
150- if ( length )
151- return sprintf ( 'SUBSTR(%s,%s,%s)' , this . escape ( p0 ) , pos . valueOf ( ) + 1 , length . valueOf ( ) ) ;
152- else
153- return sprintf ( 'SUBSTR(%s,%s)' , this . escape ( p0 ) , pos . valueOf ( ) + 1 ) ;
150+ if ( length ) {
151+ return sprintf ( 'SUBSTR(%s,%s + 1,%s)' , this . escape ( p0 ) , this . escape ( pos ) , this . escape ( length ) ) ;
152+ } else {
153+ return sprintf ( 'SUBSTR(%s,%s + 1)' , this . escape ( p0 ) , this . escape ( pos ) ) ;
154+ }
154155 }
155156 /**
156157 * Implements substring(str,pos) expression formatter.
@@ -160,10 +161,11 @@ class SqliteFormatter extends SqlFormatter {
160161 * @returns {string }
161162 */
162163 $substr ( p0 , pos , length ) {
163- if ( length )
164- return sprintf ( 'SUBSTR(%s,%s,%s)' , this . escape ( p0 ) , pos . valueOf ( ) + 1 , length . valueOf ( ) ) ;
165- else
166- return sprintf ( 'SUBSTR(%s,%s)' , this . escape ( p0 ) , pos . valueOf ( ) + 1 ) ;
164+ if ( length ) {
165+ return sprintf ( 'SUBSTR(%s,%s + 1,%s)' , this . escape ( p0 ) , this . escape ( pos ) , this . escape ( length ) ) ;
166+ } else {
167+ return sprintf ( 'SUBSTR(%s,%s + 1)' , this . escape ( p0 ) , this . escape ( pos ) ) ;
168+ }
167169 }
168170 /**
169171 * Implements length(a) expression formatter.
0 commit comments