Skip to content

Commit

Permalink
fix #47: JSON conv broken since 2.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
m6w6 committed May 3, 2023
1 parent 9ff77f9 commit 63aa327
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
10 changes: 4 additions & 6 deletions src/php_pq_params.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

#include <php.h>
#include <ext/standard/php_string.h>
#if PHP_PQ_HAVE_PHP_JSON_H
#include <php_json.h> /* we've added the include directory to INCLUDES */
#endif
#include <ext/json/php_json.h>

#include <Zend/zend_smart_str.h>
#include <Zend/zend_interfaces.h>
Expand Down Expand Up @@ -75,12 +73,12 @@ unsigned php_pq_params_add_type_oid(php_pq_params_t *p, Oid type)

static zend_string *object_param_to_string(php_pq_params_t *p, zval *zobj, Oid type)
{
#if PHP_PQ_HAVE_PHP_JSON_H && defined(PHP_PQ_OID_JSON)
#ifdef PHP_PQ_OID_JSON
smart_str str = {0};
#endif

switch (type) {
#if PHP_PQ_HAVE_PHP_JSON_H && defined(PHP_PQ_OID_JSON)
#ifdef PHP_PQ_OID_JSON
# ifdef PHP_PQ_OID_JSONB
case PHP_PQ_OID_JSONB:
# endif
Expand Down Expand Up @@ -207,7 +205,7 @@ static zend_string *array_param_to_string(php_pq_params_t *p, zval *zarr, Oid ty
struct apply_to_param_from_array_arg arg = {NULL};

switch (type) {
#if PHP_PQ_HAVE_PHP_JSON_H && defined(PHP_PQ_OID_JSON)
#ifdef PHP_PQ_OID_JSON
# ifdef PHP_PQ_OID_JSONB
case PHP_PQ_OID_JSONB:
# endif
Expand Down
8 changes: 2 additions & 6 deletions src/php_pqres.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
#include <php.h>

#include <ext/spl/spl_iterators.h>
#if PHP_PQ_HAVE_PHP_JSON_H
#include <php_json.h> /* we've added the include directory to INCLUDES */
#endif
#include <ext/json/php_json.h>

#include <libpq-events.h>

Expand Down Expand Up @@ -215,7 +213,7 @@ zval *php_pqres_typed_zval(php_pqres_t *res, Oid typ, zval *zv)
php_pqdt_from_string(zv, NULL, str->val, str->len, "Y-m-d H:i:s.uO", NULL);
break;

#if PHP_PQ_HAVE_PHP_JSON_H && defined(PHP_PQ_OID_JSON)
#ifdef PHP_PQ_OID_JSON
# ifdef PHP_PQ_OID_JSONB
case PHP_PQ_OID_JSONB:
# endif
Expand Down Expand Up @@ -1350,9 +1348,7 @@ PHP_MINIT_FUNCTION(pqres)
zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_SCALAR"), PHP_PQRES_CONV_SCALAR);
zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_ARRAY"), PHP_PQRES_CONV_ARRAY);
zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_DATETIME"), PHP_PQRES_CONV_DATETIME);
#if PHP_PQ_HAVE_PHP_JSON_H
zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_JSON"), PHP_PQRES_CONV_JSON);
#endif
zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_BYTEA"), PHP_PQRES_CONV_BYTEA);
zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_ALL"), PHP_PQRES_CONV_ALL);

Expand Down

0 comments on commit 63aa327

Please sign in to comment.