File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -234,6 +234,14 @@ Mssql.prototype.visitDrop = function(drop) {
234234 return [ 'IF EXISTS(SELECT * FROM INFORMATION_SCHEMA.TABLES ' + whereClause + ') BEGIN ' + dropResult . join ( ' ' ) + ' END' ] ;
235235} ;
236236
237+ Mssql . prototype . visitFunctionCall = function ( functionCall ) {
238+ var name = functionCall . name
239+ // override the LENGTH function since mssql calls it LEN
240+ if ( name == "LENGTH" ) name = "LEN"
241+ var txt = name + '(' + functionCall . nodes . map ( this . visit . bind ( this ) ) . join ( ', ' ) + ')' ;
242+ return [ txt ] ;
243+ } ;
244+
237245Mssql . prototype . visitOrderBy = function ( orderBy ) {
238246 var result = Mssql . super_ . prototype . visitOrderBy . call ( this , orderBy ) ;
239247 var offsetNode = orderBy . msSQLOffsetNode ;
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ var Harness = require ( './support' ) ;
4+ var Sql = require ( '../../lib' ) ;
5+
6+ var post = Harness . definePostTable ( ) ;
7+
8+ Harness . test ( {
9+ query : post . select ( Sql . functions . LENGTH ( post . content ) ) ,
10+ pg : {
11+ text : 'SELECT LENGTH("post"."content") FROM "post"' ,
12+ string : 'SELECT LENGTH("post"."content") FROM "post"'
13+ } ,
14+ sqlite : {
15+ text : 'SELECT LENGTH("post"."content") FROM "post"' ,
16+ string : 'SELECT LENGTH("post"."content") FROM "post"'
17+ } ,
18+ mysql : {
19+ text : 'SELECT LENGTH(`post`.`content`) FROM `post`' ,
20+ string : 'SELECT LENGTH(`post`.`content`) FROM `post`'
21+ } ,
22+ mssql : {
23+ text : 'SELECT LEN([post].[content]) FROM [post]' ,
24+ string : 'SELECT LEN([post].[content]) FROM [post]'
25+ } ,
26+ oracle : {
27+ text : 'SELECT LENGTH("post"."content") FROM "post"' ,
28+ string : 'SELECT LENGTH("post"."content") FROM "post"'
29+ } ,
30+ params : [ ]
31+ } ) ;
32+
You can’t perform that action at this time.
0 commit comments