blob: 32af9e8f76ec8be5acbe54d9efe7bd008b391fda (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# bug #1940
discard """
nimout: '''===
merge (A) with (B)
merge (A B) with (C)
merge (A B C) with (D)
merge (A B C D) with (E)
merge (A B C D E) with (F)
==='''
"""
type SqlStmt = tuple
sql: string
parts: int
proc sql(q: string): SqlStmt =
result.sql = q
result.parts = 1
template `&%%`(x, y: SqlStmt): SqlStmt =
const a = x
const b = y
static:
#echo "some merge"
echo "merge (", a.sql, ") with (", b.sql, ")"
const newSql = a.sql & " " & b.sql
const newParts = a.parts + b.parts
SqlStmt((sql: newSql, parts: newParts))
static:
echo "==="
let c =(sql("A") &%%
sql("B")) &%%
sql("C") &%%
sql("D") &%%
sql("E") &%%
sql("F")
echo c.sql
static:
echo "==="
|