Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getRawSchemalessAttributes() must be of the type array, string returned #45

Closed
f-liva opened this issue Mar 27, 2019 · 7 comments
Closed
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@f-liva
Copy link

f-liva commented Mar 27, 2019

When a schemaless column from db is set to NULL instead of {}, on scout:import it results in that error:

Return value of Spatie\SchemalessAttributes\SchemalessAttributes::getRawSchemalessAttributes() must be of the type array, string returned

@freekmurze
Copy link
Member

Feel free to submit a PR with tests that fixes this.

@freekmurze freekmurze added bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers labels Mar 27, 2019
@chinleung
Copy link

chinleung commented Mar 27, 2019

When a schemaless column from db is set to NULL instead of {}, on scout:import it results in that error:

Return value of Spatie\SchemalessAttributes\SchemalessAttributes::getRawSchemalessAttributes() must be of the type array, string returned

Isn't this expected behaviour though? Your database value is most likely set to NULL as a string. Can you confirm for this? 🤔

I've tried to reproduce the issue with a NULL value and it was working properly. The only way I managed was to set NULL as a string.

@terranc
Copy link

terranc commented May 31, 2019

I have the same problem at PHP v7.2.14

@securit
Copy link
Contributor

securit commented Sep 19, 2019

Yes this issue is back because the function is type hinted to an array,

    protected function getRawSchemalessAttributes(): array

but it calls the return function fromJson which returns a mixed type.

@securit
Copy link
Contributor

securit commented Mar 7, 2020

This problem appears to be an issue still, particularly for those of us using Postgres when you have a null object, ie {}::json.

@BinaryKitten
Copy link

move to close: has this been resolved by #60 ?
(came here via good first issue)

@erikn69
Copy link
Contributor

erikn69 commented Oct 28, 2021

move to close: has this been resolved by #60 ?
(came here via good first issue)

X2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

7 participants