File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
go/ql/test/library-tests/semmle/go/dataflow/flowsources/local/database Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ package test
2
+
3
+ import "gorm.io/gorm"
4
+
5
+ type User struct {}
6
+
7
+ // test querying an Association
8
+ func test_gorm_AssociationQuery (association * gorm.Association ) {
9
+ association .Find (& User {}) // $ source
10
+ }
11
+
12
+ // test querying a ConnPool
13
+ func test_gorm_ConnPoolQuery (connPool gorm.ConnPool ) {
14
+ rows , err := connPool .QueryContext (nil , "SELECT * FROM users" ) // $ source
15
+
16
+ if err != nil {
17
+ return
18
+ }
19
+
20
+ defer rows .Close ()
21
+
22
+ userRow := connPool .QueryRowContext (nil , "SELECT * FROM users WHERE id = 1" ) // $ source
23
+
24
+ ignore (userRow )
25
+ }
26
+
27
+ // test querying a DB
28
+ func test_gorm_db (db * gorm.DB ) {
29
+ db .Find (& User {}) // $ source
30
+
31
+ db .FindInBatches (& User {}, 10 , nil ) // $ source
32
+
33
+ db .FirstOrCreate (& User {}) // $ source
34
+
35
+ db .FirstOrInit (& User {}) // $ source
36
+
37
+ db .First (& User {}) // $ source
38
+
39
+ db .Last (& User {}) // $ source
40
+
41
+ db .Take (& User {}) // $ source
42
+
43
+ db .Scan (& User {}) // $ source
44
+
45
+ }
You can’t perform that action at this time.
0 commit comments