Bladeren bron

fixed get multiple when no value

develop
Robin Thoni 8 jaren geleden
bovenliggende
commit
4ad21ff978
2 gewijzigde bestanden met toevoegingen van 13 en 5 verwijderingen
  1. 5
    2
      src/Utils/DataAccess/LuDataAccess.php
  2. 8
    3
      tests/DatabaseTest.php

+ 5
- 2
src/Utils/DataAccess/LuDataAccess.php Bestand weergeven

@@ -6,6 +6,7 @@ use Illuminate\Database\Capsule\Manager as Capsule;
6 6
 use Illuminate\Database\Connection;
7 7
 use Illuminate\Database\Query\Builder;
8 8
 use Luticate\Utils\Business\LuArrayUtils;
9
+use Luticate\Utils\Business\LuStringUtils;
9 10
 use Luticate\Utils\Dbo\LuDbo;
10 11
 
11 12
 abstract class LuDataAccess {
@@ -89,8 +90,10 @@ abstract class LuDataAccess {
89 90
     {
90 91
         $query = static::resolveQuery($query);
91 92
         $string = $query->aggregate("json_agg", [static::$_table_as]);
92
-        $json = json_decode($string, true);
93
-        $data = LuArrayUtils::snakeToCamelCase($json);
93
+        if (is_null($string)) {
94
+            return [];
95
+        }
96
+        $data = LuStringUtils::convertJsonString($string);
94 97
         
95 98
         return call_user_func([static::$_dboArrayClass, 'jsonDeserialize'], $data);
96 99
     }

+ 8
- 3
tests/DatabaseTest.php Bestand weergeven

@@ -1,4 +1,5 @@
1 1
 <?php
2
+use Illuminate\Database\Query\Builder;
2 3
 use Luticate\Utils\Controller\LuticateApplication;
3 4
 use Illuminate\Database\Capsule\Manager as Capsule;
4 5
 use Luticate\Utils\DataAccess\LuDataAccess;
@@ -140,19 +141,23 @@ class DatabaseTest extends \PHPUnit_Framework_TestCase
140 141
 //                'name'      => 'mydb',
141 142
 //                'driver'    => 'pgsql',
142 143
 //                'host'      => '172.17.0.1',
143
-//                'database'  => 'intra_betaclean',
144
+//                'database'  => 'luticate2',
144 145
 //                'username'  => 'dev',
145 146
 //                'password'  => 'dev'
146 147
 //            ]
147 148
 //        ]];
148 149
 //        $app = new LuticateApplication($config);
149 150
 //        $app->setupDatabases();
150
-        
151
+//        
151 152
 //        $dbo = new TestTableDbo();
152 153
 //        $dbo->setId(11);
153 154
 //        $dbo->setSomeIntegerArray('{}');
154 155
 //        $dbo->setSomeText("lol2");
155
-
156
+//
157
+//        var_dump(TestTableDataAccess::getMultiple(function(Builder $q)
158
+//        {
159
+//            return $q->where("id", "=", 1);
160
+//        }));
156 161
 //        var_dump(TestTableDataAccess::getSingleById(1));
157 162
 //        var_dump(TestTableDataAccess::deleteMultiple(function($q)
158 163
 //        {

Laden…
Annuleren
Opslaan