Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added test for preserving values and different keyspaces with same co…
…lumn families
- Loading branch information
Mikko Koppanen
committed
Aug 29, 2011
1 parent
08f9c87
commit b4ce4bf
Showing
2 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--TEST-- | ||
Test preserving column keys and values | ||
--SKIPIF-- | ||
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> | ||
--FILE-- | ||
<?php | ||
require_once(dirname(__FILE__) . '/config.inc'); | ||
|
||
$db = new PDO($dsn); | ||
|
||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | ||
|
||
try { | ||
$db->exec ("DROP KEYSPACE {$keyspace}"); | ||
} catch (PDOException $e) {} | ||
|
||
$db->exec ("CREATE KEYSPACE {$keyspace} with strategy_class = 'SimpleStrategy' and strategy_options:replication_factor=1;"); | ||
$db->exec ("USE {$keyspace}"); | ||
|
||
$db->exec ("CREATE TABLE test_preserve (my_key text PRIMARY KEY) | ||
WITH comparator = int AND default_validation = int;"); | ||
|
||
$db->exec ("UPDATE test_preserve SET 10 = 100, 20 = 200 WHERE my_key = 'aa'"); | ||
$stmt = $db->prepare ("SELECT * FROM test_preserve WHERE my_key = 'aa'"); | ||
|
||
echo "-- preserve_values=no " . PHP_EOL; | ||
$stmt->execute (); | ||
var_dump ($stmt->fetchAll (PDO::FETCH_ASSOC)); | ||
|
||
echo "-- preserve_values=yes " . PHP_EOL; | ||
$db->setAttribute(PDO::CASSANDRA_ATTR_PRESERVE_VALUES, true); | ||
$stmt->execute (); | ||
var_dump ($stmt->fetchAll (PDO::FETCH_ASSOC)); | ||
|
||
pdo_cassandra_done ($db, $keyspace); | ||
|
||
echo "OK"; | ||
--EXPECTF-- | ||
-- preserve_values=no | ||
array(1) { | ||
[0]=> | ||
array(3) { | ||
["my_key"]=> | ||
string(2) "aa" | ||
[10]=> | ||
int(100) | ||
[20]=> | ||
int(200) | ||
} | ||
} | ||
-- preserve_values=yes | ||
array(1) { | ||
[0]=> | ||
array(3) { | ||
["my_key"]=> | ||
string(2) "aa" | ||
[10]=> | ||
string(8) "%s" | ||
[20]=> | ||
string(8) "%s" | ||
} | ||
} | ||
OK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--TEST-- | ||
Test multiple keyspaces | ||
--SKIPIF-- | ||
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> | ||
--FILE-- | ||
<?php | ||
require_once(dirname(__FILE__) . '/config.inc'); | ||
|
||
$db = new PDO($dsn); | ||
|
||
$db->exec ("CREATE KEYSPACE {$keyspace}_int with strategy_class = 'SimpleStrategy' and strategy_options:replication_factor=1;"); | ||
$db->exec ("CREATE KEYSPACE {$keyspace}_text with strategy_class = 'SimpleStrategy' and strategy_options:replication_factor=1;"); | ||
|
||
$db->exec ("USE {$keyspace}_int"); | ||
$db->exec ("CREATE TABLE my_cf (my_key text PRIMARY KEY) | ||
WITH comparator = int AND default_validation = int;"); | ||
|
||
$db->exec ("UPDATE my_cf SET 10 = 100, 20 = 200 WHERE my_key = 'aa'"); | ||
|
||
$db->exec ("USE {$keyspace}_text"); | ||
$db->exec ("CREATE TABLE my_cf (my_key text PRIMARY KEY)"); | ||
$db->exec ("UPDATE my_cf SET hello = 'world', test = 'column' WHERE my_key = 'aa'"); | ||
|
||
$db->exec ("USE {$keyspace}_int"); | ||
$results = $db->query ("SELECT * FROM my_cf WHERE my_key = 'aa'"); | ||
var_dump ($results->fetchAll(PDO::FETCH_ASSOC)); | ||
|
||
$db->exec ("USE {$keyspace}_text"); | ||
$results = $db->query ("SELECT * FROM my_cf WHERE my_key = 'aa'"); | ||
var_dump ($results->fetchAll(PDO::FETCH_ASSOC)); | ||
|
||
$db->exec ("DROP KEYSPACE {$keyspace}_int"); | ||
$db->exec ("DROP KEYSPACE {$keyspace}_text"); | ||
|
||
echo "OK"; | ||
--EXPECT-- | ||
array(1) { | ||
[0]=> | ||
array(3) { | ||
["my_key"]=> | ||
string(2) "aa" | ||
[10]=> | ||
int(100) | ||
[20]=> | ||
int(200) | ||
} | ||
} | ||
array(1) { | ||
[0]=> | ||
array(3) { | ||
["my_key"]=> | ||
string(2) "aa" | ||
["hello"]=> | ||
string(5) "world" | ||
["test"]=> | ||
string(6) "column" | ||
} | ||
} | ||
OK |