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

Indexed arrays no longer work in Alice 3.x #995

Open
majermi4 opened this issue Jun 20, 2019 · 3 comments
Open

Indexed arrays no longer work in Alice 3.x #995

majermi4 opened this issue Jun 20, 2019 · 3 comments

Comments

@majermi4
Copy link

Hello, our company has used Alice for fixture generation for a long time now we have a lot of complex fixtures in our project and we utilized parsing of indexed arrays to data formatters of our custom data fakers in Alice 2.x.

With the upgrade to Alice 3.x, however, this is no longer possible and passing of indexed arrays leads to internal token strings being given to the data fakers.

Example fixture file:
Screenshot 2019-06-20 at 08 16 38

Results in value given to data faker:
Screenshot 2019-06-20 at 08 21 03

I would like to ask if whether it is a bug in the new Alice version or if it was never meant to work this way and happened to work by chance in Alice 2.x. If that was the case, does anybody know of a clean way to passing indexed arrays to data fakers?

Thank you for answers and for a great library! Michal.

@theofidry
Copy link
Member

If that worked in 2.x it was pure luck :) I think a way to do it would be:

data: <dynamicObjectData(<(["property1" => intval(1)])>)>

Not sure that it will work though :/ It might be easier to just put everything in the faker provider directly.

@majermi4
Copy link
Author

majermi4 commented Jun 20, 2019

@theofidry: Thank you for the fast reply.

I tried the format you recommended and it works only with a small adjustment when you take away space around the "=>".

So this works: <dynamicObjectData(<(["property1"=>intval(1)])>)>

It is a bit cumbersome to use and if there was a chance at some point, it would be great if alice supported indexed arrays by default.

For simple cases, it would be ok to put everything in a faker directly, however, in the scale of what we're building, it is unfortunately not maintainable to create custom logic for each different scenario.

Thank you, Mike.

@theofidry
Copy link
Member

I think a more viable long term plan would be #601 (comment).

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

No branches or pull requests

2 participants