[PECL-CVS] [pecl-database-pdo_oci] main: Add test for inserting BOOLEAN data type (supported from Oracle DB 21c+)

[email protected] (Sharad Chandran R)
Newsgroups php.pecl.cvs
Message-ID <[email protected]>
Author: Sharad Chandran R (sharadraju)
Date: 2026-01-06T10:19:31+05:30

Commit: https://github.com/php/pecl-database-pdo_oci/commit/29bcc8c9e1cf50ee38f608a109c76c2fb2e549b6
Raw diff: https://github.com/php/pecl-database-pdo_oci/commit/29bcc8c9e1cf50ee38f608a109c76c2fb2e549b6.diff

Add test for inserting BOOLEAN data type (supported from Oracle DB 21c+)

Changed paths:
  A  tests/pdo_oci_insert_boolean.phpt


Diff:

diff --git a/tests/pdo_oci_insert_boolean.phpt b/tests/pdo_oci_insert_boolean.phpt
new file mode 100644
index 0000000..6b92039
--- /dev/null
+++ b/tests/pdo_oci_insert_boolean.phpt
@@ -0,0 +1,72 @@
+--TEST--
+PDO_OCI: Insert BOOLEAN values into BOOLEAN column (Oracle 21c+)
+--EXTENSIONS--
+pdo
+pdo_oci
+--SKIPIF--
+<?php
+require(getenv('PDO_TEST_DIR').'/pdo_test.inc');
+$db = PDOTest::factory();
+
+$version = $db->getAttribute(PDO::ATTR_SERVER_VERSION);
+preg_match('/^(\d+)\./', $version, $matches);
+$majorVersion = (int)$matches[1];
+if ($majorVersion < 21) {
+    die('skip BOOLEAN type supported from Oracle Database 21c');
+}
+
+PDOTest::skip();
+?>
+--FILE--
+<?php
+
+require_once(getenv('PDO_TEST_DIR').'/pdo_test.inc');
+$db = PDOTest::factory();
+
+// Drop table if exists (ignore error if it doesn't exist)
+try {
+    $db->exec("DROP TABLE test_bool");
+} catch (PDOException $e) {
+    // Ignore
+}
+
+// Create table
+$db->exec("CREATE TABLE test_bool (id NUMBER, bool_val BOOLEAN)");
+
+// Insert true
+$stmt = $db->prepare("INSERT INTO test_bool (id, bool_val) VALUES (1, :val)");
+$val = true;
+$stmt->bindParam(':val', $val, PDO::PARAM_BOOL);
+$stmt->execute();
+
+// Insert false
+$stmt = $db->prepare("INSERT INTO test_bool (id, bool_val) VALUES (2, :val)");
+$val = false;
+$stmt->bindParam(':val', $val, PDO::PARAM_BOOL);
+$stmt->execute();
+
+// Fetch and dump
+$stmt = $db->query("SELECT id, bool_val FROM test_bool ORDER BY id");
+var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
+
+// Cleanup
+$db->exec("DROP TABLE test_bool");
+
+?>
+--EXPECT--
+array(2) {
+  [0]=>
+  array(2) {
+    ["ID"]=>
+    string(1) "1"
+    ["BOOL_VAL"]=>
+    string(1) "1"
+  }
+  [1]=>
+  array(2) {
+    ["ID"]=>
+    string(1) "2"
+    ["BOOL_VAL"]=>
+    string(1) "0"
+  }
+}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.