Modified pdo tests to work with column encryption (#1051)

This commit is contained in:
Jenny Tam 2019-11-06 08:21:38 -08:00 committed by GitHub
parent 051328782d
commit e30752fc6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View file

@ -101,7 +101,18 @@ try {
echo "Done\n";
} catch (PdoException $e) {
echo $e->getMessage() . PHP_EOL;
if (isAEConnected()) {
// The Always Encrypted feature does not support emulate prepare for binding parameters
$expected = '*Parameterized statement with attribute PDO::ATTR_EMULATE_PREPARES is not supported in a Column Encryption enabled Connection.';
if (!fnmatch($expected, $e->getMessage())) {
echo "Unexpected exception caught when connecting with Column Encryption enabled:\n";
echo $e->getMessage() . PHP_EOL;
} else {
echo "Done\n";
}
} else {
echo $e->getMessage() . PHP_EOL;
}
}
?>

View file

@ -22,7 +22,7 @@ function insertRead($conn, $pdoStrParam, $value, $testCase, $id, $encoding = fal
{
global $p, $tableName;
$sql = "INSERT INTO $tableName VALUES (:value)";
$sql = "INSERT INTO $tableName (Col1) VALUES (:value)";
$options = array(PDO::ATTR_EMULATE_PREPARES => false); // it's false by default anyway
$stmt = $conn->prepare($sql, $options);