Skip to content

Commit

Permalink
Fix and test for handling correct 'NULL' output from gettype()
Browse files Browse the repository at this point in the history
  • Loading branch information
twalder-docnet committed Jan 5, 2016
1 parent a40b723 commit 4e12e02
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/GDS/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ protected function configureValueParamForQuery($obj_val, $mix_value)
break;

case 'null':
case 'NULL':
$obj_val->setStringValue(null);
break;

Expand Down
1 change: 1 addition & 0 deletions src/GDS/Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ protected function determineDynamicType($mix_value)

case 'resource':
case 'null':
case 'NULL':
case 'unknown type':
default:
$int_dynamic_type = Schema::PROPERTY_STRING;
Expand Down
24 changes: 24 additions & 0 deletions tests/ProtoBufGqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,30 @@ public function testFetchOneStringParam()
$this->apiProxyMock->verify();
}

/**
* GQL Fetch ONE with one string parameter
*/
public function testFetchOneNullParam()
{
$str_gql = "SELECT * FROM Kind WHERE property = @param";
$obj_request = $this->getBasicFetchRequest();

$obj_gql_query = $obj_request->mutableGqlQuery();
$obj_gql_query->setAllowLiteral(TRUE);
$obj_gql_query->setQueryString($str_gql . " LIMIT 1");
$obj_arg = $obj_gql_query->addNameArg();
$obj_arg->setName('param');
$obj_arg->mutableValue()->setStringValue(null);

$this->apiProxyMock->expectCall('datastore_v4', 'RunQuery', $obj_request, new \google\appengine\datastore\v4\RunQueryResponse());

$obj_store = $this->createBasicStore();
$obj_result = $obj_store->fetchOne($str_gql, ['param' => null]);

$this->assertEquals($obj_result, null);
$this->apiProxyMock->verify();
}

/**
* Fetch all
*/
Expand Down

0 comments on commit 4e12e02

Please sign in to comment.