Skip to content

Commit 6f0ddff

Browse files
authored
Merge pull request #3837 from Laravel-Backpack/fix-for-pg-complain-about-empty-queries
Prevent DB query when value is empty
2 parents 76993b8 + 91e8875 commit 6f0ddff

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/resources/views/crud/fields/relationship/fetch.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
// make sure the $field['value'] takes the proper value
2727
// and format it to JSON, so that select2 can parse it
2828
$current_value = old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $field['default'] ?? '';
29-
if ($current_value != false) {
29+
if (!empty($current_value) || is_int($current_value)) {
3030
switch (gettype($current_value)) {
3131
case 'array':
3232
$current_value = $connected_entity

src/resources/views/crud/fields/relationship/fetch_or_create.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// and format it to JSON, so that select2 can parse it
1313
$current_value = old(square_brackets_to_dots($field['name'])) ?? old($field['name']) ?? $field['value'] ?? $field['default'] ?? '';
1414
15-
if ($current_value !== false) {
15+
if (!empty($current_value) || is_int($current_value)) {
1616
switch (gettype($current_value)) {
1717
case 'array':
1818
$current_value = $connected_entity

src/resources/views/crud/fields/relationship/relationship_select.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
$current_value = old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $field['default'] ?? '';
1919
2020
21-
if ($current_value != false) {
21+
if (!empty($current_value) || is_int($current_value)) {
2222
switch (gettype($current_value)) {
2323
case 'array':
2424
$current_value = $connected_entity

0 commit comments

Comments
 (0)