question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Field relationship_select causes QueryException when validation fails.

See original GitHub issue

Bug report

Refs; Probably related to this PR: https://github.com/Laravel-Backpack/CRUD/pull/4002

What I did

Created/Updated resource that contains values inside relationship_select field and validated request. Validation rules doesn’t have anything to do with relationship_select CRUD field.

Field Definition

        CRUD::addField([
            'name'    => 'origins',
            'label'   => 'Assosciate Origins.',
            'tab'   => 'Relationships',
            'wrapper' => [
                'class' => 'form-group col-md-6',
            ],

            'pivot_selector' => [
                'wrapper' => [
                    'class' => 'form-group col-md-6',
                ]
            ],
            'pivotFields' => [
                [
                    'name'    => 'as',
                    'type'    => 'text',
                    'wrapper' => [
                        'class' => 'form-group col-md-6',
                    ],
                ],

            ],

What I expected to happen

If validation passes:

  • Create/Update Resource

If validation fails:

  • Redirect back with validation errors being displayed.

What happened

Illuminate\Database\QueryException
SQLSTATE[HY093]: Invalid parameter number (SQL: select * from `origins` where `id` in (2)) (View: /xxx/xxx/xxx/vendor/backpack/crud/src/resources/views/crud/fields/relationship/relationship_select.blade.php)

This only occurs when validation fails and relationship_select field has any data.

Is it a bug in the latest version of Backpack?

After I run composer update backpack/crud the bug… is it still there?

Backpack, Laravel, PHP, DB version

When I run php artisan backpack:version the output is:

### PHP VERSION:
PHP 8.0.13 (cli) (built: Nov 22 2021 09:50:43) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.13, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.13, Copyright (c), by Zend Technologies

### LARAVEL VERSION:
v8.77.0@148b0df9eaac9f89bebb6b6fbbb0e9874e62ecc7

### BACKPACK VERSION:
4.2.x-dev@69d7047ae60a2c45a0cd02c9e56553f42e961d72

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:18 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
pxpmcommented, Aug 3, 2022

@tabacitu I think this is fixed for long time now.

I am going to close and re-open if someone pings here.

Cheers

1reaction
pxpmcommented, Feb 3, 2022

This is fixed I think.

Please re-open or comment if I am wrong.

Thanks for testing 4.2 @PitchRE , since this issue was opened alot of stuff have been added/fixed regarding relationships specially in the last days with nested relations.

Let us know if you find something broken while using that branch 😃

Pedro

Read more comments on GitHub >

github_iconTop Results From Across the Web

Field Value Validation and custom error message
I want to have some field value validations, and want to show custom error message,. e.g. you must be 18 years old validation...
Read more >
Primefaces bug - field update not working after validation fails ...
So, to finish - everything works without problem until I intentionally cause validation error by trying to submit empty form.
Read more >
Unique validation fails when multiple serverside sessions are ...
So there is a unique validation constraint on the "Name" field in our Lock table (Always validate, no override). We then use set...
Read more >
Ugly reporting of failing validators on Create Issue - Jira
When a (custom) validator is placed on the "Create Issue" transition, and the validator fails, the error message: Is placed at the top...
Read more >
List has no rows for assignment to SObject" error with custom ...
debug(LoggingLevel.ERROR, e.getMessage()); } // Change the Custom Setting back to put validation rules back in to effect. case 00012193.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found