public function testUpdateTtlTimestamp()
 {
     $stmt = CqlQueryBuilder::update('tbl', ['field1' => 'value1'])->usingTtl(50)->usingTimestamp(123456);
     $this->assertEquals('UPDATE "tbl" USING TTL 50 AND TIMESTAMP 123456 SET "field1" = \'value1\'', CqlAssembler::stringify($stmt));
     $assembler = new CqlAssembler($stmt);
     $this->assertEquals('UPDATE "tbl" USING TTL ? AND TIMESTAMP ? SET "field1" = ?', $assembler->getQuery());
     $this->assertEquals([50, 123456, 'value1'], $assembler->getParameters());
 }
 public function testInsertTtlTimestamp()
 {
     $stmt = CqlQueryBuilder::insertInto('tbl', 'field1', 'field2')->values('value1', 'value2')->usingTtl(50)->usingTimestamp(123456);
     $this->assertEquals('INSERT INTO "tbl" ("field1", "field2") VALUES (\'value1\', \'value2\') USING TTL 50 AND TIMESTAMP 123456', CqlAssembler::stringify($stmt));
     $assembler = new CqlAssembler($stmt);
     $this->assertEquals('INSERT INTO "tbl" ("field1", "field2") VALUES (?, ?) USING TTL ? AND TIMESTAMP ?', $assembler->getQuery());
     $this->assertEquals(['value1', 'value2', 50, 123456], $assembler->getParameters());
 }
 public function testAssemble()
 {
     $expression = new StringExpression();
     $expression->setValue(1);
     $this->assertEquals('1', QueryAssembler::stringify($expression));
     $expression->setValue('abc');
     $this->assertEquals('"abc"', QueryAssembler::stringify($expression));
     $expression->setValue('a"b"c');
     $this->assertEquals('"a\\"b\\"c"', QueryAssembler::stringify($expression));
     $expression->setValue('a"b"c');
     $this->assertEquals("'a\"b\"c'", CqlAssembler::stringify($expression));
     $expression->setValue("a'b'c");
     $this->assertEquals("'a''b''c'", CqlAssembler::stringify($expression));
     $expression->setValue("a''b''c");
     $this->assertEquals("'a''''b''''c'", CqlAssembler::stringify($expression));
     $expression->setValue("'a'b'c'");
     $this->assertEquals("'''a''b''c'''", CqlAssembler::stringify($expression));
 }
Exemplo n.º 4
0
 public function testTableExpression()
 {
     $this->assertEquals('"testTable"', CqlAssembler::stringify(TableExpression::create('testTable')));
 }
 public function testAssemble()
 {
     $statement = CqlQueryBuilder::select(AllSelectExpression::create());
     $statement->addClause(new AllowFilteringClause());
     $this->assertEquals('SELECT * ALLOW FILTERING', CqlAssembler::stringify($statement));
 }
Exemplo n.º 6
0
 public function testSetExpression()
 {
     $this->assertEquals("{'test',1}", CqlAssembler::stringify(SetExpression::create(['test', 1])));
     $this->assertEquals("\"testfield\" + {'test'}", CqlAssembler::stringify(AdditionExpression::create(FieldExpression::create('testfield'), SetExpression::create('test'))));
 }
Exemplo n.º 7
0
 public function testListFieldExpression()
 {
     $this->assertEquals("myfield[5] = 'test'", CqlAssembler::stringify(EqualPredicate::create(ListFieldExpression::create('myfield', 5), 'test')));
 }
Exemplo n.º 8
0
 public function testMapFieldExpression()
 {
     $this->assertEquals("myfield['mykey'] = 'test'", CqlAssembler::stringify(EqualPredicate::create(MapFieldExpression::create('myfield', 'mykey'), 'test')));
 }