Skip to content

Update BelongsTo relation makes from old_values ID Integer insead of String type #763

@NoahNxT

Description

@NoahNxT
Q A
Bug? yes
New Feature? no
Framework Laravel
Framework version 9.48.0
Package version 13.0
PHP version 8.1

Actual Behaviour

When updatinga BelongsTo relation, the old_values id is parsed to an Int instead of a string.
This makes searching with whereJsonContains unpossible because you'll have to always check for both types

image

This is how I need to check in the audits table for a presence value now:

Audit::whereJsonContains('old_values', ['protocol_id' => $this->id])
            ->orWhereJsonContains('old_values', ['protocol_id' => (string)$this->id])
            ->orWhereJsonContains('new_values', ['protocol_id' => $this->id])
            ->exists();

Expected Behaviour

When updating a BelongsTo relation, the old_value of the id should be parsed to a string like any other action.

**old_values

"model_id":"9",

Steps to Reproduce

  1. Make a belongsTo Many relation
  2. Attach the BelongsTo
  3. Update the BelongsTo
  4. Now you can see the different type in the old_values column

Possible Solutions

Hard cast to (Int)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions