diff --git a/src/Util/Generator.php b/src/Util/Generator.php index a968f335c..3d18f9ff5 100755 --- a/src/Util/Generator.php +++ b/src/Util/Generator.php @@ -201,7 +201,11 @@ class Generator $maschera = Generator::complete($maschera, [], $date); $maschera = str_replace('#', '%', $maschera); - $query = Manager::table($table)->select($field)->where($field, 'like', $maschera)->orderByRaw($order); + //Lunghezza maschera + $mask_length = strlen($maschera); + + $query = Manager::table($table)->select($field)->where($field, 'like', $maschera)->whereRaw('LENGTH( numero_esterno )<='.$mask_length)->orderByRaw('LENGTH(numero_esterno) DESC')->orderByRaw($order); + foreach ($where as $and) { $query->whereRaw($and);