MCPcopy
hub / github.com/AlaSQL/alasql / toString

Method toString

src/statements/Select.js:32–82  ·  view source on GitHub ↗

* Convert SELECT to SQL string representation

()

Source from the content-addressed store, hash-verified

30 * Convert SELECT to SQL string representation
31 */
32 toString() {
33 let s = 'SELECT ';
34 if (this.distinct) {
35 s += 'DISTINCT ';
36 }
37 if (this.columns && this.columns.length > 0) {
38 s += this.columns
39 .map(col => {
40 let cs = col.toString ? col.toString() : String(col);
41 if (col.as) {
42 cs += ' AS ' + col.as;
43 }
44 return cs;
45 })
46 .join(', ');
47 } else {
48 s += '*';
49 }
50 if (this.from) {
51 s +=
52 ' FROM ' +
53 this.from
54 .map(f => {
55 let fs = f.toString ? f.toString() : String(f);
56 if (f.as) {
57 fs += ' AS ' + f.as;
58 }
59 return fs;
60 })
61 .join(', ');
62 }
63 if (this.where) {
64 s += ' WHERE ' + (this.where.toString ? this.where.toString() : String(this.where));
65 }
66 if (this.group) {
67 s += ' GROUP BY ' + this.group.map(g => g.toString()).join(', ');
68 }
69 if (this.having) {
70 s += ' HAVING ' + this.having.toString();
71 }
72 if (this.order) {
73 s += ' ORDER BY ' + this.order.map(o => o.toString()).join(', ');
74 }
75 if (this.limit !== null) {
76 s += ' LIMIT ' + this.limit;
77 }
78 if (this.offset !== null) {
79 s += ' OFFSET ' + this.offset;
80 }
81 return s;
82 }
83}
84
85/**

Callers 15

xlsx.mjsFile · 0.45
SSF_generalFunction · 0.45
write_quoted_printableFunction · 0.45
parse_madFunction · 0.45
write_madFunction · 0.45
cc2strFunction · 0.45
getdatastrFunction · 0.45
escapexmlFunction · 0.45
escapehtmlFunction · 0.45
escapexlmlFunction · 0.45
utf8readbFunction · 0.45
utf8readcFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected