예제 #1
0
 /**
  * This request is re-used a lot in the tests
  *
  * @return \google\appengine\datastore\v4\RunQueryRequest
  */
 private function getBasicFetchRequest()
 {
     $obj_request = new \google\appengine\datastore\v4\RunQueryRequest();
     $obj_request->mutableReadOptions();
     $obj_partition = $obj_request->mutablePartitionId();
     $obj_partition->setDatasetId('Dataset');
     return $obj_request;
 }
예제 #2
0
 /**
  * GQL Fetch ONE with one string parameter and namespace
  */
 public function testFetchOneStringParam()
 {
     $str_gql = "SELECT * FROM Kind WHERE property = @param";
     $obj_request = new \google\appengine\datastore\v4\RunQueryRequest();
     $obj_request->setSuggestedBatchSize(1000);
     $obj_request->mutableReadOptions();
     $obj_request->mutablePartitionId()->setDatasetId('Dataset')->setNamespace('Test');
     $obj_gql_query = $obj_request->mutableGqlQuery()->setAllowLiteral(TRUE)->setQueryString($str_gql . " LIMIT 1");
     $obj_arg = $obj_gql_query->addNameArg();
     $obj_arg->setName('param');
     $obj_arg->mutableValue()->setStringValue('test');
     $this->apiProxyMock->expectCall('datastore_v4', 'RunQuery', $obj_request, new \google\appengine\datastore\v4\RunQueryResponse());
     $obj_result = $this->getBookstoreWithTestNamespace()->fetchOne($str_gql, ['param' => 'test']);
     $this->assertEquals($obj_result, null);
     $this->apiProxyMock->verify();
 }
예제 #3
0
 public function testMixedOverlappingQuotedParamFallback()
 {
     $obj_deny_proxy = new DenyGQLProxyMock();
     $obj_deny_proxy->init($this);
     $obj_request = new \google\appengine\datastore\v4\RunQueryRequest();
     $obj_request->setSuggestedBatchSize(1000);
     $obj_request->mutableReadOptions();
     $obj_partition = $obj_request->mutablePartitionId();
     $obj_partition->setDatasetId('Dataset');
     $obj_query = $obj_request->mutableQuery();
     $obj_query->addKind()->setName('Book and "stuff"');
     $obj_comp_filter = $obj_query->mutableFilter()->mutableCompositeFilter()->setOperator(\google\appengine\datastore\v4\CompositeFilter\Operator::AND_);
     $obj_prop_filter1 = $obj_comp_filter->addFilter()->mutablePropertyFilter()->setOperator(\google\appengine\datastore\v4\PropertyFilter\Operator::EQUAL);
     $obj_prop_filter1->mutableProperty()->setName('author');
     $obj_prop_filter1->mutableValue()->setStringValue('William "Will" Shakespeare');
     $obj_prop_filter2 = $obj_comp_filter->addFilter()->mutablePropertyFilter()->setOperator(\google\appengine\datastore\v4\PropertyFilter\Operator::EQUAL);
     $obj_prop_filter2->mutableProperty()->setName('isbn');
     $obj_prop_filter2->mutableValue()->setStringValue("1234'5'6789");
     $obj_deny_proxy->expectCall('datastore_v4', 'RunQuery', $obj_request, new \google\appengine\datastore\v4\RunQueryResponse());
     $obj_gateway = new GDS\Gateway\ProtoBuf('Dataset');
     $obj_store = new GDS\Store('Book', $obj_gateway);
     $obj_store->fetchAll('SELECT * FROM `Book and "stuff"` WHERE author = \'William "Will" Shakespeare\' AND isbn = "1234\'5\'6789"');
     $obj_deny_proxy->verify();
 }