DATA-DOG / go-sqlmock

Sql mock driver for golang to test database interactions
Other
6.07k stars 408 forks source link

Wrong condition to check Begin options #342

Open kpeu3i opened 1 week ago

kpeu3i commented 1 week ago

There is a bug on this line https://github.com/DATA-DOG/go-sqlmock/blob/master/sqlmock.go#L256

    if expected.txOpts != nil &&
        expected.txOpts.Isolation != opts.Isolation &&
        expected.txOpts.ReadOnly != opts.ReadOnly {
        return nil, fmt.Errorf("expected transaction options do not match: %+v, got: %+v", expected.txOpts, opts)
    }

but should be:

    if expected.txOpts != nil &&
        (expected.txOpts.Isolation != opts.Isolation || expected.txOpts.ReadOnly != opts.ReadOnly) {
        return nil, fmt.Errorf("expected transaction options do not match: %+v, got: %+v", expected.txOpts, opts)
    }
kpeu3i commented 2 days ago

@ninadingole please check