1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: fix shared_element_lock.vv test (#14960)

This commit is contained in:
yuyi 2022-07-06 15:43:36 +08:00 committed by GitHub
parent 59d6ca0c95
commit bb2223c8b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 7 deletions

View File

@ -188,13 +188,16 @@ pub fn (db DB) exec_one(query string) ?Row {
// exec_param_many executes a query with the provided parameters
pub fn (db DB) exec_param_many(query string, params []string) ?[]Row {
unsafe {
mut param_vals := []&char{len: params.len}
for i in 0 .. params.len {
param_vals[i] = params[i].str
}
res := C.PQexecParams(db.conn, query.str, params.len, 0, param_vals.data, 0, 0, 0)
res := C.PQexecParams(db.conn, query.str, params.len, 0, param_vals.data, 0, 0,
0)
return db.handle_error_or_result(res, 'exec_param_many')
}
}
pub fn (db DB) exec_param2(query string, param string, param2 string) ?[]Row {

View File

@ -1,4 +1,4 @@
vlib/v/checker/tests/shared_element_lock.vv:43:11: warning: arrays of references need to be initialized right away (unless used inside `unsafe`)
vlib/v/checker/tests/shared_element_lock.vv:43:11: warning: arrays of references need to be initialized right away, therefore `len:` cannot be used (unless inside `unsafe`)
41 | shared g := Pro{}
42 | g.pers.age = 42
43 | mut h := []shared Pro{len: 3}