File tree 2 files changed +31
-2
lines changed
2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -309,10 +309,20 @@ return {
309
309
} ) ;
310
310
let name ;
311
311
if ( column . alias ) name = column . alias . value ;
312
- else name = column . expression ;
312
+ else name = this . toSql ( column . expression ) ;
313
+
314
+ let mappedTo ;
315
+ if ( column . expression . type == 'identifier' ) {
316
+ mappedTo = { column : column . expression . value } ;
317
+ } else if ( column . expression . type == 'column' ) {
318
+ mappedTo = { column : column . expression . name , table : column . expression . table } ;
319
+ }
320
+
313
321
returnColumns . push ( {
314
322
name : name ,
315
- sourceColumns : sourceColumns
323
+ expression : column . expression ,
324
+ sourceColumns : sourceColumns ,
325
+ mappedTo
316
326
} ) ;
317
327
} ) ;
318
328
}
Original file line number Diff line number Diff line change @@ -8,6 +8,25 @@ const tests = [
8
8
operation : 'select' ,
9
9
} ,
10
10
toSql : '(select * from (`test`))'
11
+ } , {
12
+ sql : 'select x from test' ,
13
+ toSql : '(select `x` from (`test`))' ,
14
+ expected : {
15
+ returnColumns : [ {
16
+ expression : {
17
+ type : 'identifier' ,
18
+ value : 'x'
19
+ } ,
20
+ mappedTo : {
21
+ column : 'x'
22
+ } ,
23
+ name : '`x`' ,
24
+ sourceColumns : [ {
25
+ type : 'identifier' ,
26
+ value : 'x'
27
+ } ]
28
+ } ]
29
+ }
11
30
} , {
12
31
sql : [
13
32
'select * # comments!' ,
You can’t perform that action at this time.
0 commit comments