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

Moving typing from entity to mapping schema #7

Closed
SerafimArts opened this issue Apr 11, 2019 · 7 comments
Closed

Moving typing from entity to mapping schema #7

SerafimArts opened this issue Apr 11, 2019 · 7 comments

Comments

@SerafimArts
Copy link
Contributor

SerafimArts commented Apr 11, 2019

I think that types should be defined in the schema, not in Entity. In this case, we can allow for more flexible behavior (have several different types in the same entity depending on the repository source). In that case, when we need to guarantee the types in entity, we can use the PHP 7.4+ properties typing.

Actual

class Entity
{
    /** @column(type=string) */
    protected $some;
}
new Schema([
    'user' => [Schema::COLUMNS  => ['some']]
]);

Expected

class Entity
{
    protected $some;
}
new Schema([
    'user' => [Schema::COLUMNS  => ['some' => 'string']]
]);
@SerafimArts SerafimArts changed the title Mapping location architectural problem Moving typing from entity to mapping schema Apr 11, 2019
@wolfy-j
Copy link
Contributor

wolfy-j commented Apr 11, 2019

It is actually already in schema, see section TYPECAST. The column type drives this value as default and tells the driver how to configure the database.

@SerafimArts
Copy link
Contributor Author

Hmmm... In this case, my proposal becomes irrelevant =)

@wolfy-j
Copy link
Contributor

wolfy-j commented Apr 11, 2019

I can also find your original comments about using one entity for two sources. This is possible as well, check Classless example in tests :)

@SerafimArts
Copy link
Contributor Author

@wolfy-j I understood this after I started reading the source code =)

Therefore, instead of closing the issue, I was just corrected it.

@wolfy-j
Copy link
Contributor

wolfy-j commented Apr 11, 2019

OK. I will try to explain it all in the documentation but the hard separation between the entity and it's mapping was a very critical aspect of the design.

I assume it will be more questions when we will describe it in details (60 pages :( ).

Please let me know if you have any high-level questions in the meantime, I would glad to make sure that direction is correct and we do not miss anything.

@SerafimArts
Copy link
Contributor Author

kk. We still have time to talk about this topic on phprussia conf ;)

@wolfy-j
Copy link
Contributor

wolfy-j commented Apr 11, 2019

LOL, that too.

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

No branches or pull requests

2 participants