| @@ 7-72 (lines=66) @@ | ||
| 4 | ||
| 5 | use evseevnn\Cassandra; |
|
| 6 | ||
| 7 | class QueryNegativeBigIntTest extends Setup\QueryTestCase |
|
| 8 | { |
|
| 9 | ||
| 10 | public function testBigIntRow() |
|
| 11 | { |
|
| 12 | self::$connection->query('CREATE TABLE BigIntTest (foo bigint PRIMARY KEY, bar bigint)'); |
|
| 13 | self::$connection->query( |
|
| 14 | 'INSERT INTO BigIntTest (foo, bar) VALUES (:foo, :bar)', |
|
| 15 | ['foo' => '-2', 'bar' => '-52'] |
|
| 16 | ); |
|
| 17 | $result = self::$connection->query('SELECT * FROM BigIntTest WHERE foo = :foo', ['foo' => '-2']); |
|
| 18 | $this->assertEquals('-52', $result[0]['bar']); |
|
| 19 | $this->assertEquals('-2', $result[0]['foo']); |
|
| 20 | } |
|
| 21 | ||
| 22 | public function testBigIntMap() |
|
| 23 | { |
|
| 24 | self::$connection->query('CREATE TABLE BigIntMapTest (foo bigint PRIMARY KEY, bar map<bigint,bigint>)'); |
|
| 25 | self::$connection->query( |
|
| 26 | 'INSERT INTO BigIntMapTest (foo, bar) VALUES (:foo, :bar)', |
|
| 27 | ['foo' => '-2', 'bar' => ['-52' => '-25']] |
|
| 28 | ); |
|
| 29 | $result = self::$connection->query('SELECT * FROM BigIntMapTest WHERE foo = :foo', ['foo' => '-2']); |
|
| 30 | $this->assertEquals(['-52' => '-25'], $result[0]['bar']); |
|
| 31 | $this->assertEquals('-2', $result[0]['foo']); |
|
| 32 | } |
|
| 33 | ||
| 34 | public function testBigIntSet() |
|
| 35 | { |
|
| 36 | self::$connection->query('CREATE TABLE BigIntSetTest (foo bigint PRIMARY KEY, bar set<bigint>)'); |
|
| 37 | self::$connection->query( |
|
| 38 | 'INSERT INTO BigIntSetTest (foo, bar) VALUES (:foo, :bar)', |
|
| 39 | ['foo' => '-2', 'bar' => ['-25', '-52']] |
|
| 40 | ); |
|
| 41 | $result = self::$connection->query('SELECT * FROM BigIntSetTest WHERE foo = :foo', ['foo' => '-2']); |
|
| 42 | $this->assertEquals([-52, -25], $result[0]['bar']); |
|
| 43 | $this->assertEquals('-2', $result[0]['foo']); |
|
| 44 | //according to Spec, this should always be returned alphabetically. |
|
| 45 | self::$connection->query( |
|
| 46 | 'INSERT INTO BigIntSetTest (foo, bar) VALUES (:foo, :bar)', |
|
| 47 | ['foo' => '-22', 'bar' => ['-52', '-25']] |
|
| 48 | ); |
|
| 49 | $result = self::$connection->query('SELECT * FROM BigIntSetTest WHERE foo = :foo', ['foo' => '-22']); |
|
| 50 | $this->assertEquals([-52, -25], $result[0]['bar']); |
|
| 51 | } |
|
| 52 | ||
| 53 | public function testBigIntList() |
|
| 54 | { |
|
| 55 | self::$connection->query('CREATE TABLE BigIntListTest (foo bigint PRIMARY KEY, bar list<bigint>)'); |
|
| 56 | self::$connection->query( |
|
| 57 | 'INSERT INTO BigIntListTest (foo, bar) VALUES (:foo, :bar)', |
|
| 58 | ['foo' => '-2', 'bar' => ['-52', '-25']] |
|
| 59 | ); |
|
| 60 | $result = self::$connection->query('SELECT * FROM BigIntListTest WHERE foo = :foo', ['foo' => '-2']); |
|
| 61 | $this->assertEquals(['-52', '-25'], $result[0]['bar']); |
|
| 62 | $this->assertEquals('-2', $result[0]['foo']); |
|
| 63 | //according to Spec, this should be returned in index order |
|
| 64 | self::$connection->query( |
|
| 65 | 'INSERT INTO BigIntListTest (foo, bar) VALUES (:foo, :bar)', |
|
| 66 | ['foo' => '-22', 'bar' => ['-25', '-52']] |
|
| 67 | ); |
|
| 68 | $result = self::$connection->query('SELECT * FROM BigIntListTest WHERE foo = :foo', ['foo' => '-22']); |
|
| 69 | $this->assertEquals(['-25', '-52'], $result[0]['bar']); |
|
| 70 | } |
|
| 71 | ||
| 72 | } |
|
| @@ 7-69 (lines=63) @@ | ||
| 4 | ||
| 5 | use evseevnn\Cassandra; |
|
| 6 | ||
| 7 | class QueryNegativeIntTest extends Setup\QueryTestCase |
|
| 8 | { |
|
| 9 | ||
| 10 | public function testIntRow() |
|
| 11 | { |
|
| 12 | self::$connection->query('CREATE TABLE IntTest (foo int PRIMARY KEY, bar int)'); |
|
| 13 | self::$connection->query('INSERT INTO IntTest (foo, bar) VALUES (:foo, :bar)', ['foo' => '-2', 'bar' => '-52']); |
|
| 14 | $result = self::$connection->query('SELECT * FROM IntTest WHERE foo = :foo', ['foo' => '-2']); |
|
| 15 | $this->assertEquals('-52', $result[0]['bar']); |
|
| 16 | $this->assertEquals('-2', $result[0]['foo']); |
|
| 17 | } |
|
| 18 | ||
| 19 | public function testIntMap() |
|
| 20 | { |
|
| 21 | self::$connection->query('CREATE TABLE IntMapTest (foo int PRIMARY KEY, bar map<int,int>)'); |
|
| 22 | self::$connection->query( |
|
| 23 | 'INSERT INTO IntMapTest (foo, bar) VALUES (:foo, :bar)', |
|
| 24 | ['foo' => '-2', 'bar' => ['-52' => '-25']] |
|
| 25 | ); |
|
| 26 | $result = self::$connection->query('SELECT * FROM IntMapTest WHERE foo = :foo', ['foo' => '-2']); |
|
| 27 | $this->assertEquals(['-52' => '-25'], $result[0]['bar']); |
|
| 28 | $this->assertEquals('-2', $result[0]['foo']); |
|
| 29 | } |
|
| 30 | ||
| 31 | public function testIntSet() |
|
| 32 | { |
|
| 33 | self::$connection->query('CREATE TABLE IntSetTest (foo int PRIMARY KEY, bar set<int>)'); |
|
| 34 | self::$connection->query( |
|
| 35 | 'INSERT INTO IntSetTest (foo, bar) VALUES (:foo, :bar)', |
|
| 36 | ['foo' => '-2', 'bar' => ['-25', '-52']] |
|
| 37 | ); |
|
| 38 | $result = self::$connection->query('SELECT * FROM IntSetTest WHERE foo = :foo', ['foo' => '-2']); |
|
| 39 | $this->assertEquals([-52, -25], $result[0]['bar']); |
|
| 40 | $this->assertEquals('-2', $result[0]['foo']); |
|
| 41 | //according to Spec, this should always be returned alphabetically. |
|
| 42 | self::$connection->query( |
|
| 43 | 'INSERT INTO IntSetTest (foo, bar) VALUES (:foo, :bar)', |
|
| 44 | ['foo' => '-22', 'bar' => ['-52', '-25']] |
|
| 45 | ); |
|
| 46 | $result = self::$connection->query('SELECT * FROM IntSetTest WHERE foo = :foo', ['foo' => '-22']); |
|
| 47 | $this->assertEquals([-52, -25], $result[0]['bar']); |
|
| 48 | } |
|
| 49 | ||
| 50 | public function testIntList() |
|
| 51 | { |
|
| 52 | self::$connection->query('CREATE TABLE IntListTest (foo int PRIMARY KEY, bar list<int>)'); |
|
| 53 | self::$connection->query( |
|
| 54 | 'INSERT INTO IntListTest (foo, bar) VALUES (:foo, :bar)', |
|
| 55 | ['foo' => '-2', 'bar' => ['-52', '-25']] |
|
| 56 | ); |
|
| 57 | $result = self::$connection->query('SELECT * FROM IntListTest WHERE foo = :foo', ['foo' => '-2']); |
|
| 58 | $this->assertEquals(['-52', '-25'], $result[0]['bar']); |
|
| 59 | $this->assertEquals('-2', $result[0]['foo']); |
|
| 60 | //according to Spec, this should be returned in index order |
|
| 61 | self::$connection->query( |
|
| 62 | 'INSERT INTO IntListTest (foo, bar) VALUES (:foo, :bar)', |
|
| 63 | ['foo' => '-22', 'bar' => ['-25', '-52']] |
|
| 64 | ); |
|
| 65 | $result = self::$connection->query('SELECT * FROM IntListTest WHERE foo = :foo', ['foo' => '-22']); |
|
| 66 | $this->assertEquals(['-25', '-52'], $result[0]['bar']); |
|
| 67 | } |
|
| 68 | ||
| 69 | } |
|