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

Adding a MappingFieldsTransformer #18

Open
programarivm opened this issue Apr 22, 2018 · 2 comments
Open

Adding a MappingFieldsTransformer #18

programarivm opened this issue Apr 22, 2018 · 2 comments

Comments

@programarivm
Copy link
Contributor

programarivm commented Apr 22, 2018

Hi there,

Thanks for sharing Extraload with the community. It would be great if some more examples and documentation could be added to the library.

Why would we need a MappingFieldsTransformer?

I noticed that many times we'll go like this.

Source books:

isbn, title, author

Destination my_books:

foo, bar

In this example we're loading the contents of books.isbn into my_books.foo; the same thing goes for books.author (we load its content into my_books.bar). And note the books.title field is not used in the target table.

The example above shows a 3 -> 2 mapping between the tables books and my_books because we want to (1) change the names of the fields in the target table and (2) be able to choose which source table fields are actually loaded into the destination table.

More specifically, this 3 -> 2 mapping in particular could be described like this in the MappingFieldsTransformer:

$mapping = [
    'author' => 'foo',
    'title' => 'bar'
];

I believe this is very common -- I'll soon share a MappingFieldTransformer if all this makes sense. In fact it would be good to have a bunch of common transformers:

  1. MappingFieldsTransfomer
  2. TrimTransformer
    ...

And write a few more examples on using them.

@programarivm programarivm changed the title Adding a MappingFieldsTransformer Adding a MappingFieldsTransformer Apr 22, 2018
@programarivm
Copy link
Contributor Author

Just added a MapFieldsTransformer as described at this README.md in section Doctrine query with field transformation loaded into a table

@umpirsky
Copy link
Owner

umpirsky commented Apr 23, 2018

I like the idea, posted my thoughts in #17 (comment). 👍

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