Skip to content
This repository has been archived by the owner on Dec 10, 2018. It is now read-only.

Lack of "ID" in key name results in exception #86

Closed
spencerwasden opened this issue Nov 9, 2018 · 1 comment
Closed

Lack of "ID" in key name results in exception #86

spencerwasden opened this issue Nov 9, 2018 · 1 comment

Comments

@spencerwasden
Copy link

I'm using a legacy schema that won't be modified. A uuid column named "CreatedBy" does not contain "id" or "uuid", so getRelatedBinaryKeyName doesn't return the attribute with suffix. Commenting out the preg_match line and just returning "{$attribute}{$suffix}" fixes the issue:

    public function getRelatedBinaryKeyName($attribute): string
    {
        $suffix = $this->getUuidSuffix();

      //return preg_match('/(?:uu)?id/i', $attribute) ? "{$attribute}{$suffix}" : $attribute;
        return "{$attribute}{$suffix}";
    }

Since the CreatedBy column is provided in the model's $uuids array, should getRelatedBinaryKeyName really be doing that check for "uuid" or "id"? If so, could this be made to be conditional based on a config setting?

The exception is thrown from here in Illuminate/Http/JsonResponse.php:

if (! $this->hasValidJson(json_last_error())) {
    throw new InvalidArgumentException(json_last_error_msg());
}

Exception:
InvalidArgumentException. Malformed UTF-8 characters, possibly incorrectly encoded

@freekmurze
Copy link
Member

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants