Skip to content

Version 8.0.3 breaks support for non-integer keys  #486

@specialtactics

Description

@specialtactics
Q A
Bug? yes
New Feature? no
Framework Laravel
Framework version 5.7.25
Package version >=8.0.3
PHP version 7.2.x

Actual Behaviour

This PR here
https://github.com/owen-it/laravel-auditing/pull/448/files

For this issue (from what I understand):
#432

Will actually break any project using non-numeric (or non-integer) primary key IDs. In our case, we are using UUIDs (which I would think is quite common these days).

The end result is that any update to the underlying model will wipe all audits and it will no longer have any related audits.

Expected Behaviour

As laravel supports non-integer keys, so should this package. Update shouldn't break existing functionality.

Steps to Reproduce

Create a new model in Laravel with the following properties and as a string in the database (for field type)

    /**
     * @var bool Set to false for UUID keys
     */
    public $incrementing = false;

    /**
     * @var string Set to string for UUID keys
     */
    protected $keyType = 'string';

Deploy the auditable trait on it, and see what happens on model update.

Possible Solutions

The auditable_id cast to integer needs to be removed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions