sqlite: fix volume lookups with partial names

Requires the trailing `%` to work correctly, see
        https://www.sqlitetutorial.net/sqlite-like/

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
Valentin Rothberg
2023-02-23 13:56:58 +01:00
parent 495314a16a
commit 5d2d609be4

View File

@ -2033,7 +2033,7 @@ func (s *SQLiteState) LookupVolume(name string) (*Volume, error) {
return nil, define.ErrDBClosed return nil, define.ErrDBClosed
} }
rows, err := s.conn.Query("SELECT JSON FROM VolumeConfig WHERE Name LIKE ?;", name) rows, err := s.conn.Query("SELECT JSON FROM VolumeConfig WHERE Name LIKE ?;", name+"%")
if err != nil { if err != nil {
return nil, fmt.Errorf("querying database for volume %s: %w", name, err) return nil, fmt.Errorf("querying database for volume %s: %w", name, err)
} }