-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a911619
commit 5a4b1d0
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
go/ql/test/library-tests/semmle/go/dataflow/flowsources/local/database/test_gorm.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package test | ||
|
||
import "gorm.io/gorm" | ||
|
||
type User struct{} | ||
|
||
// test querying an Association | ||
func test_gorm_AssociationQuery(association *gorm.Association) { | ||
association.Find(&User{}) // $ source | ||
} | ||
|
||
// test querying a ConnPool | ||
func test_gorm_ConnPoolQuery(connPool gorm.ConnPool) { | ||
rows, err := connPool.QueryContext(nil, "SELECT * FROM users") // $ source | ||
|
||
if err != nil { | ||
return | ||
} | ||
|
||
defer rows.Close() | ||
|
||
userRow := connPool.QueryRowContext(nil, "SELECT * FROM users WHERE id = 1") // $ source | ||
|
||
ignore(userRow) | ||
} | ||
|
||
// test querying a DB | ||
func test_gorm_db(db *gorm.DB) { | ||
db.Find(&User{}) // $ source | ||
|
||
db.FindInBatches(&User{}, 10, nil) // $ source | ||
|
||
db.FirstOrCreate(&User{}) // $ source | ||
|
||
db.FirstOrInit(&User{}) // $ source | ||
|
||
db.First(&User{}) // $ source | ||
|
||
db.Last(&User{}) // $ source | ||
|
||
db.Take(&User{}) // $ source | ||
|
||
db.Scan(&User{}) // $ source | ||
|
||
} |