-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcompiler_test.go
692 lines (620 loc) · 17.5 KB
/
compiler_test.go
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
package analyst
import (
"bytes"
"database/sql"
"fmt"
xlsx "github.com/360EntSecGroup-Skylar/excelize"
"github.com/michaelbironneau/analyst/aql"
"github.com/michaelbironneau/analyst/engine"
. "github.com/smartystreets/goconvey/convey"
"os"
"testing"
)
func TestGlobal(t *testing.T) {
script := `
GLOBAL 'InitializeInputTable' (
CREATE TABLE test (
ID Number,
Name Text
);
INSERT INTO test (ID, Name) VALUES (1, 'Bob');
)
GLOBAL 'InitializeOutputTable' (
CREATE TABLE test2 (
ID Number,
Name Text
);
)
QUERY 'Test' FROM GLOBAL (
SELECT * FROM test
) INTO GLOBAL WITH (TABLE = 'test2')
`
db, err := sql.Open(globalDbDriver, globalDbConnString)
defer db.Close()
Convey("Given a script making use of GLOBAL", t, func() {
Convey("It should be processed correctly and generate the expected results", func() {
So(err, ShouldBeNil)
err := ExecuteString(script, &RuntimeOptions{})
So(err, ShouldBeNil)
var row struct {
ID int
Name string
}
r := db.QueryRow("SELECT * FROM test2 LIMIT 1")
err = r.Scan(&row.ID, &row.Name)
So(err, ShouldBeNil)
So(row.ID, ShouldEqual, 1)
So(row.Name, ShouldEqual, "Bob")
})
})
}
func TestCompilerDataLiteralAndHooks(t *testing.T) {
script := `
DATA 'Values' EXTERN 'test.json'
WITH (FORMAT = 'JSON_ARRAY',
COLUMNS = 'Number,Letter');
TRANSFORM 'Total' FROM BLOCK Values (
AGGREGATE SUM(Number) AS Total
) INTO CONSOLE WITH (OUTPUT_FORMAT = 'JSON')
`
Convey("Given a literal data source and a query", t, func() {
Convey("It should run without errors", func() {
l := engine.NewConsoleLogger(engine.Trace)
buf := bytes.NewBufferString("")
replaceReaderHook := engine.DestinationHook(func(s string, d engine.Destination) (engine.Destination, error) {
cd, _ := d.(*engine.ConsoleDestination)
cd.Writer = buf
return nil, nil
})
err := ExecuteString(script, &RuntimeOptions{nil, l, []interface{}{replaceReaderHook}, nil, ""})
So(err, ShouldBeNil)
So(buf.String(), ShouldEqual, "[{\"Total\":3}]")
})
})
}
func TestCompilerAssertions(t *testing.T) {
script := `
DATA 'Values' (
[
["Hello, World"],
["Hello, World"]
]
)
INTO CONSOLE
WITH (FORMAT = 'JSON_ARRAY',
COLUMNS = 'Word')
TEST Values WITH ASSERTIONS (
COLUMN Word HAS UNIQUE VALUES
)
`
script2 := `
DATA 'Values' (
[
["Hello, World"],
["Hello, World"]
]
)
INTO CONSOLE
WITH (FORMAT = 'JSON_ARRAY',
COLUMNS = 'Word')
TEST Values WITH ASSERTIONS (
IT OUTPUTS AT LEAST 2 ROWS;
IT OUTPUTS AT MOST 2 ROWS
)
`
Convey("Given a literal data source and a failing test", t, func() {
Convey("It should return an error", func() {
l := engine.NewConsoleLogger(engine.Trace)
buf := bytes.NewBufferString("")
replaceReaderHook := engine.DestinationHook(func(s string, d engine.Destination) (engine.Destination, error) {
cd, _ := d.(*engine.ConsoleDestination)
cd.Writer = buf
return nil, nil
})
err := TestString(script, &RuntimeOptions{nil, l, []interface{}{replaceReaderHook}, nil, ""})
So(err, ShouldNotBeNil)
So(buf.String(), ShouldHaveLength, 0) //Should have been replaced by DevNull destination
})
})
Convey("Given a literal data source and some passing tests", t, func() {
Convey("It should return no error", func() {
l := engine.NewConsoleLogger(engine.Trace)
buf := bytes.NewBufferString("")
replaceReaderHook := engine.DestinationHook(func(s string, d engine.Destination) (engine.Destination, error) {
cd, _ := d.(*engine.ConsoleDestination)
cd.Writer = buf
return nil, nil
})
err := TestString(script2, &RuntimeOptions{nil, l, []interface{}{replaceReaderHook}, nil, ""})
So(err, ShouldBeNil)
So(buf.String(), ShouldHaveLength, 0) //Should have been replaced by DevNull destination
})
})
}
func TestCompilerDataLiteralSourceDest(t *testing.T) {
script := `
DATA 'MyMessage' (
[
["Hello, World"]
]
) INTO CONSOLE WITH (COLUMNS = 'Message', OUTPUT_FORMAT='JSON')
`
Convey("Given a literal data source console dest", t, func() {
Convey("It should run without errors", func() {
l := engine.NewConsoleLogger(engine.Trace)
buf := bytes.NewBufferString("")
replaceReaderHook := engine.DestinationHook(func(s string, d engine.Destination) (engine.Destination, error) {
cd, _ := d.(*engine.ConsoleDestination)
cd.Writer = buf
return nil, nil
})
err := ExecuteString(script, &RuntimeOptions{nil, l, []interface{}{replaceReaderHook}, nil, ""})
So(err, ShouldBeNil)
So(buf.String(), ShouldEqual, "[{\"Message\":\"Hello, World\"}]")
})
})
}
func TestCompilerHTTPAutoSQL(t *testing.T) {
script := `
CONNECTION 'WebAPI' (
DRIVER = 'http',
URL = 'https://chroniclingamerica.loc.gov/awardees.json',
JSON_PATH = 'awardees',
COLUMNS = 'URL, Name'
)
QUERY 'Aggregate' FROM CONNECTION WebAPI (
--Select how many awardees are universities
SELECT 'The Magic Answer Is', COUNT(*) As NumberOfUniversityAwardees FROM WebAPI
WHERE Name LIKE '%university%'
) INTO CONSOLE
`
Convey("Given a script using an HTTP connection and a QUERY", t, func() {
Convey("It should run without errors", func() {
l := engine.NewConsoleLogger(engine.Trace)
err := ExecuteString(script, &RuntimeOptions{nil, l, nil, nil, ""})
//l.Close()
So(err, ShouldBeNil)
})
})
}
func TestCompiler(t *testing.T) {
script := `
CONNECTION 'DB' (
Driver = 'sqlite3',
ConnectionString = './engine/testing/test_insert.db'
)
CONNECTION 'Workbook' (
Driver = 'Excel',
File = './output.xlsx'
)
QUERY 'DumpData' FROM CONNECTION DB (
SELECT 1 AS 'Id', 'Bob' AS 'Name'
) INTO CONNECTION Workbook
WITH (Sheet = 'TestSheet', Range = 'A1:B1',
Columns = 'Id, Name')
`
Convey("Given a coordinator and an Excel data destination", t, func() {
l := engine.NewConsoleLogger(engine.Trace)
err := ExecuteString(script, &RuntimeOptions{nil, l, nil, nil, ""})
So(err, ShouldBeNil)
_, err = os.Stat("./output.xlsx")
os.Remove("./output.xlsx") //best effort cleanup attempt
So(err, ShouldBeNil)
})
}
func TestUnmanagedTransaction(t *testing.T) {
script := `
SET MANAGED_TRANSACTION = 'False';
EXEC 'Initialize' FROM GLOBAL (
CREATE TABLE ContactStats3 (
id integer PRIMARY KEY,
first_name text NOT NULL,
calls real
);
);
QUERY 'InsertResults' FROM GLOBAL (
SELECT 1 AS id, 'Bob' AS first_name, 8 AS calls
UNION ALL
SELECT 2 AS id, 'Steven' AS first_name, 0 AS calls
UNION ALL
SELECT 3 AS id, 'Jack' AS first_name, 1 AS calls
) INTO GLOBAL WITH (TABLE = 'ContactStats3',
ROWS_PER_BATCH=2)
AFTER Initialize
`
Convey("Given a script that uses unmanaged transaction", t, func() {
err := ExecuteString(script, &RuntimeOptions{})
So(err, ShouldBeNil)
db, err := sql.Open(globalDbDriver, globalDbConnString)
defer db.Close()
So(err, ShouldBeNil)
rows, err := db.Query("Select first_name, calls FROM ContactStats3")
So(err, ShouldBeNil)
var res struct {
name string
sum float64
}
defer rows.Close()
var count int
for rows.Next() {
count++
err := rows.Scan(&res.name, &res.sum)
So(err, ShouldBeNil)
if res.name == "Bob" {
So(res.sum, ShouldEqual, 8.0)
} else if res.name == "Steven" {
So(res.sum, ShouldEqual, 0.0)
} else if res.name == "Jack" {
So(res.sum, ShouldEqual, 1.0)
} else {
So(res.name, ShouldBeIn, []string{"Bob", "Steven", "Jack"}) //fails
}
}
So(count, ShouldEqual, 3)
})
}
func TestCompilerWithExecs(t *testing.T) {
script := `
GLOBAL 'Initialize' (
CREATE TABLE ContactStats2 (
id integer PRIMARY KEY,
first_name text NOT NULL,
calls real
);
);
EXEC 'InsertResults' FROM GLOBAL (
INSERT INTO ContactStats2 (id, first_name, calls) VALUES (1, 'Bob', 8);
INSERT INTO ContactStats2 (id, first_name, calls) VALUES (2, 'Steven', 0);
)
`
Convey("Given a script that uses EXEC blocks", t, func() {
err := ExecuteString(script, &RuntimeOptions{})
So(err, ShouldBeNil)
db, err := sql.Open(globalDbDriver, globalDbConnString)
defer db.Close()
So(err, ShouldBeNil)
rows, err := db.Query("Select first_name, calls FROM ContactStats2")
So(err, ShouldBeNil)
var res struct {
name string
sum float64
}
defer rows.Close()
var count int
for rows.Next() {
count++
err := rows.Scan(&res.name, &res.sum)
So(err, ShouldBeNil)
if res.name == "Bob" {
So(res.sum, ShouldEqual, 8.0)
} else if res.name == "Steven" {
So(res.sum, ShouldEqual, 0.0)
} else {
So(res.name, ShouldBeIn, []string{"Bob", "Steven"}) //fails
}
}
So(count, ShouldEqual, 2)
})
}
func TestCompilerWithLookupTransform(t *testing.T) {
script := `
/**
Create global tables with the base and lookup tables,
so that we can test the lookup transform.
**/
GLOBAL 'CreateTables' (
CREATE TABLE LookupTable (
id INT PRIMARY KEY,
first_name TEXT
);
CREATE TABLE BaseTable (
lookup_id INT PRIMARY KEY,
last_name TEXT
);
CREATE TABLE JoinedTable (
first_name TEXT,
last_name TEXT
);
);
GLOBAL 'SeedTables' (
INSERT INTO LookupTable VALUES (1, 'Bob');
INSERT INTO LookupTable VALUES (2, 'John');
INSERT INTO LookupTable VALUES (3, 'Steve');
INSERT INTO BaseTable VALUES (1, 'Bobbertson');
INSERT INTO BaseTable VALUES (2, 'Johnson');
);
QUERY 'FirstNames' FROM GLOBAL (
SELECT id, first_name FROM LookupTable
);
QUERY 'LastNames' FROM GLOBAL (
SELECT lookup_id, last_name FROM BaseTable
);
TRANSFORM 'Join' FROM BLOCK FirstNames, BLOCK LastNames (
LOOKUP FirstNames.first_name, LastNames.last_name FROM FirstNames
INNER JOIN LastNames ON FirstNames.id = LastNames.lookup_id
) INTO GLOBAL WITH(Table = 'JoinedTable')
`
Convey("Given a script that uses builtin transforms", t, func() {
err := ExecuteString(script, &RuntimeOptions{})
So(err, ShouldBeNil)
db, err := sql.Open(globalDbDriver, globalDbConnString)
defer db.Close()
So(err, ShouldBeNil)
rows, err := db.Query("Select first_name, last_name from JoinedTable order by first_name")
So(err, ShouldBeNil)
var res struct {
first string
last string
}
defer rows.Close()
var count int
var (
haveBob bool
haveJohn bool
)
for rows.Next() {
count++
err := rows.Scan(&res.first, &res.last)
So(err, ShouldBeNil)
if res.first == "Bob" {
haveBob = true
So(res.last, ShouldEqual, "Bobbertson")
} else if res.first == "John" {
haveJohn = true
So(res.last, ShouldEqual, "Johnson")
} else {
So(res.first, ShouldBeIn, []string{"Bob", "John"}) //fails
}
}
So(haveBob, ShouldBeTrue)
So(haveJohn, ShouldBeTrue)
So(count, ShouldEqual, 2)
})
}
func TestCompilerWithAggregateTransform(t *testing.T) {
script := `
SET Table = 'Result2';
GLOBAL 'Initialize' (
CREATE TABLE ContactStats (
id integer PRIMARY KEY,
first_name text NOT NULL,
number_of_calls real
);
INSERT INTO ContactStats (id, first_name, number_of_calls) VALUES (1, 'Bob', 5);
INSERT INTO ContactStats (id, first_name, number_of_calls) VALUES (2, 'Steven', 0);
INSERT INTO ContactStats (id, first_name, number_of_calls) VALUES (3, 'Bob', 3);
);
GLOBAL 'Result' (
CREATE TABLE Result2 (
first_name text PRIMARY KEY,
calls real
);
)
QUERY 'Fetch' FROM GLOBAL (
SELECT * FROM ContactStats
)
TRANSFORM 'SumByFirstName' FROM BLOCK Fetch (
AGGREGATE first_name, SUM(number_of_calls) As calls
GROUP BY first_name
) INTO GLOBAL
`
Convey("Given a script that uses builtin transforms", t, func() {
err := ExecuteString(script, &RuntimeOptions{})
So(err, ShouldBeNil)
db, err := sql.Open(globalDbDriver, globalDbConnString)
defer db.Close()
So(err, ShouldBeNil)
rows, err := db.Query("Select first_name, calls FROM Result2")
So(err, ShouldBeNil)
var res struct {
name string
sum float64
}
defer rows.Close()
var count int
for rows.Next() {
count++
err := rows.Scan(&res.name, &res.sum)
So(err, ShouldBeNil)
if res.name == "Bob" {
So(res.sum, ShouldEqual, 8.0)
} else if res.name == "Steven" {
So(res.sum, ShouldEqual, 0.0)
} else {
So(res.name, ShouldBeIn, []string{"Bob", "Steven"}) //fails
}
}
So(count, ShouldEqual, 2)
})
}
func TestCompilerWithParameters(t *testing.T) {
script := `
DECLARE @Id;
GLOBAL 'Initialize' (
CREATE TABLE Contacts (
id integer PRIMARY KEY,
first_name text NOT NULL
);
INSERT INTO Contacts (id, first_name) VALUES (1, 'Bob');
INSERT INTO Contacts (id, first_name) VALUES (2, 'Steven');
INSERT INTO Contacts (id, first_name) VALUES (3, 'Jack');
);
QUERY 'GetId' FROM GLOBAL (
SELECT 1 AS 'Id'
) INTO PARAMETER (@Id);
QUERY 'GetName' FROM GLOBAL (
SELECT 4 As Id, first_name FROM Contacts
WHERE id = ?
)
USING PARAMETER @Id
INTO GLOBAL WITH (Table = 'Contacts')
AFTER GetId
`
SkipConvey("Given a script that uses parameters", t, func() {
err := ExecuteString(script, &RuntimeOptions{})
So(err, ShouldBeNil)
db, err := sql.Open(globalDbDriver, globalDbConnString)
defer db.Close()
So(err, ShouldBeNil)
rows, err := db.Query("Select first_name FROM Contacts ORDER BY id")
So(err, ShouldBeNil)
var names []string
defer rows.Close()
for rows.Next() {
var name string
err := rows.Scan(&name)
So(err, ShouldBeNil)
names = append(names, name)
}
So(names, ShouldResemble, []string{"Bob", "Steven", "Jack", "Bob"})
})
}
func TestCompilerWithEmail(t *testing.T) {
script := `
CONNECTION 'SendTestEmail' (
DRIVER = 'MANDRILL',
API_KEY = 'XIrAnHAcpAMpOONkJYjiNg',
RECIPIENTS = 'Test <[email protected]>, Test2 <[email protected]>',
TEMPLATE = 'analyst-test',
SPLIT = 'True'
)
DATA 'Values' (
[
["Bob Bobbertson", 123.123],
["Steve Stevenson", 234.234]
]
)WITH (FORMAT = 'JSON_ARRAY', COLUMNS = 'Engineer,Current');
TRANSFORM 'PopulateEmail' FROM BLOCK Values (
AGGREGATE Engineer, Current
GROUP BY Engineer, Current
) INTO CONNECTION SendTestEmail
`
Convey("Given a script that uses email", t, func() {
Convey("It should run without errors", func() {
err := ExecuteString(script, &RuntimeOptions{})
So(err, ShouldBeNil)
})
})
}
func TestCompilerWithTransform(t *testing.T) {
script := `
CONNECTION 'Workbook' (
Driver = 'Excel',
File = './output_transform.xlsx'
)
QUERY 'SliceOfData' FROM GLOBAL (
SELECT 1 AS 'Value'
UNION ALL
SELECT -1 AS 'Value'
UNION ALL
SELECT 2 AS 'Value'
)
QUERY 'SliceOfData2' FROM GLOBAL (
SELECT 10 AS 'Value'
UNION ALL
SELECT 11 AS 'Value'
UNION ALL
SELECT -2 AS 'Value'
)
TRANSFORM PLUGIN 'FilterNegatives' FROM BLOCK SliceOfData, BLOCK SliceOfData2 ()
INTO CONNECTION Workbook
WITH (
Sheet = 'TestSheet', Range = 'A1:A*',
Columns = 'Value', Multisource_Order = 'Sequential',
Executable = 'python', Args = '["./test_filter.py"]', Overwrite = 'True'
)
`
Convey("Given a script with a transform and an Excel data destination", t, func() {
l := engine.NewConsoleLogger(engine.Trace)
Convey("It should execute without error", func() {
err := ExecuteString(script, &RuntimeOptions{nil, l, nil, nil, ""})
So(err, ShouldBeNil)
_, err = os.Stat("./output_transform.xlsx")
So(err, ShouldBeNil)
Convey("It should return the correct output", func() {
x, err := xlsx.OpenFile("./output_transform.xlsx")
So(err, ShouldBeNil)
So(x.GetCellValue("TestSheet", "A1"), ShouldEqual, "1")
So(x.GetCellValue("TestSheet", "A2"), ShouldEqual, "2")
So(x.GetCellValue("TestSheet", "A3"), ShouldEqual, "10")
So(x.GetCellValue("TestSheet", "A4"), ShouldEqual, "11")
os.Remove("./output_transform.xlsx") //best effort cleanup attempt
})
})
})
}
func TestConnectionMap(t *testing.T) {
script := `
CONNECTION 'DB' (
Driver = 'sqlite3',
ConnectionString = './engine/testing/test_insert.db'
)
CONNECTION 'Workbook' (
Driver = 'Excel',
File = './output.xlsx'
)
QUERY 'DumpData' FROM CONNECTION DB (
SELECT 1 AS 'Id', 'Bob' AS 'Name'
) INTO CONNECTION Workbook
WITH (Sheet = 'Test', Range = '[0,0]:[0,N]')
`
js, err := aql.ParseString(script)
Convey("Given a valid script with connections", t, func() {
So(err, ShouldBeNil)
So(len(js.Connections), ShouldEqual, 2)
Convey("The connection map should be correctly generated", func() {
c, err := connectionMap(js)
So(err, ShouldBeNil)
So(c["workbook"].Driver, ShouldEqual, "Excel")
So(c["db"].Driver, ShouldEqual, "sqlite3")
})
})
}
func TestTxManagerRollback(t *testing.T) {
script := `
CONNECTION 'DB' (
Driver = 'sqlite3',
ConnectionString = 'tx_manager_rollback_test.db'
)
EXEC 'CreateTables' FROM CONNECTION DB (
CREATE TABLE Test (
id INT PRIMARY KEY
);
)
--Insert a single value into TEST
EXEC 'InsertOne' FROM CONNECTION DB (
INSERT INTO Test VALUES (1);
) AFTER CreateTables;
EXEC 'InsertTwo' FROM CONNECTION DB (
INSERT INTO Test VALUES (2);
INSERT INTO Test VALUES (1); --violates primary key
) AFTER InsertOne;
QUERY 'Dump' FROM CONNECTION DB (
SELECT * FROM Test
)
INTO CONSOLE
AFTER InsertTwo
`
l := engine.NewConsoleLogger(engine.Trace)
Convey("Given a script with EXECs one of which violates PK constraint", t, func() {
ExecuteString(script, &RuntimeOptions{nil, l, nil, nil, ""})
Convey("All writes should get rolled back", func() {
//So(err, ShouldNotBeNil)
db, err := sql.Open(globalDbDriver, "tx_manager_rollback_test.db")
So(err, ShouldBeNil)
rows, err := db.Query("SELECT * FROM Test")
db.Close()
os.Remove("tx_manager_rollback_test.db")
So(err, ShouldNotBeNil) //DDL ops are transactional in sqlite3 so CREATE TABLE should have been rolled back
if rows == nil {
return
}
defer rows.Close()
for rows.Next() {
var id int
rows.Scan(&id)
fmt.Printf("Found id %v\n", id)
}
})
})
}