Skip to content

Conversation

@mpyw
Copy link
Contributor

@mpyw mpyw commented Nov 17, 2021

@codecov
Copy link

codecov bot commented Nov 17, 2021

@mpyw mpyw marked this pull request as ready for review November 17, 2021 10:33
@mpyw
Copy link
Contributor Author

mpyw commented Nov 17, 2021

@yitam Hi! Where should I add new tests?

@mpyw mpyw changed the title Fix restoring PDO::ATTR_ERRMODE when PDO::lastInsertId() call failed Nov 17, 2021
@yitam
Copy link
Contributor

yitam commented Nov 17, 2021

Thanks @mpyw but we only accept PRs to dev branch. For new tests please add them to test\functional\pdo_sqlsrv

@mpyw mpyw marked this pull request as draft November 17, 2021 19:45
@ghost
Copy link

ghost commented Nov 17, 2021

CLA assistant check
All CLA requirements met.

@mpyw mpyw marked this pull request as ready for review November 17, 2021 20:50
@yitam
Copy link
Contributor

yitam commented Nov 18, 2021

@mpyw your change looks good. Thanks for catching this.

For your test, it's similar to our existing test "pdo_lastInsertId.phpt", but your calls to lastInsertId() would not end up in the exception would they?

To prove that your change has any effect, please put something like the following after one of the calls to lastInsertId(), to force an exception to occur:

    $tsql = "SELECT * FROM dummy";
    $conn->exec($tsql);

Also, change the catch block to be something like this:

} catch (PDOException $e) {
    var_dump($e->getMessage());
    exit;
}
@mpyw
Copy link
Contributor Author

mpyw commented Nov 18, 2021

@yitam
Copy link
Contributor

yitam commented Nov 18, 2021

@mpyw you don't have to match the exact message, but this is my suggestion (please drop the test tables first):

    dropTable($conn, "table3");

    $tsql = "SELECT * FROM dummy";
    $conn->exec($tsql);

    unset($conn);
} catch (PDOException $e) {
    print_r($e->getMessage());
    exit;
}


?>
--EXPECTREGEX--
string\(3\) "200"
string\(3\) "102"
(string\(0\) ""|bool\(false\))
.*Invalid object name \'dummy\'\.
@yitam yitam merged commit f52fb48 into microsoft:dev Nov 18, 2021
@mpyw mpyw deleted the fix-restoring-error-mode-on-last-insert-id-error branch November 19, 2021 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants