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

Open
f-liva opened this issue Mar 27, 2019 · 4 comments

Comments

@f-liva
Copy link

@f-liva 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

This comment has been minimized.

Copy link
Member

@freekmurze freekmurze commented Mar 27, 2019

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

@chinleung

This comment has been minimized.

Copy link

@chinleung 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

This comment has been minimized.

Copy link

@terranc terranc commented May 31, 2019

I have the same problem at PHP v7.2.14

@securit

This comment has been minimized.

Copy link

@securit 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.