mirror of https://github.com/VinGarcia/ksql.git
Remove gorm dependency from QueryOne()
parent
cdad1673f0
commit
13bd087cee
14
kiss_orm.go
14
kiss_orm.go
|
@ -101,15 +101,17 @@ func (c Client) QueryOne(
|
||||||
return fmt.Errorf("kissorm: expected to receive a pointer to struct, but got: %T", record)
|
return fmt.Errorf("kissorm: expected to receive a pointer to struct, but got: %T", record)
|
||||||
}
|
}
|
||||||
|
|
||||||
it := c.db.Raw(query, params...)
|
rows, err := c.db.DB().QueryContext(ctx, query, params...)
|
||||||
if it.Error != nil {
|
if err != nil {
|
||||||
return it.Error
|
return err
|
||||||
}
|
}
|
||||||
it = it.Scan(record)
|
defer rows.Close()
|
||||||
if it.Error != nil && it.Error.Error() == "record not found" {
|
|
||||||
|
if !rows.Next() {
|
||||||
return ErrRecordNotFound
|
return ErrRecordNotFound
|
||||||
}
|
}
|
||||||
return it.Error
|
|
||||||
|
return scanRows(rows, record)
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryChunks is meant to perform queries that returns
|
// QueryChunks is meant to perform queries that returns
|
||||||
|
|
Loading…
Reference in New Issue