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

[DDC-1663]Native SQL Query Result Set Mappings #293

Merged
merged 20 commits into from
Apr 16, 2012

Conversation

FabioBatSilva
Copy link
Member

Hello

http://www.doctrine-project.org/jira/browse/DDC-1663

This patch adds support for native query mapping
This is not complete yet but a would like to get your sugestions about this.

The following annotations have been added :

@NamedNativeQuery : Is used to specify a native SQL named query.

@SqlResultSetMapping: Is used to specify the mapping of the result of a native SQL query.

@EntityResult: References an entity in the SELECT clause of a SQL query.

@FieldResult: Is used to map the columns specified in the SELECT list of the query to the properties or fields of the entity class.

@ColumnResult : References name of a column in the SELECT clause of a SQL query. (scalar values)

It is a very big feature so any suggestion are welcome. :)

Thanks

* @param array $queryMapping
* @return ResultSetMappingBuilder
*/
public function addNamedNativeQueryMapping(ClassMetadataInfo $class, array $queryMapping)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you refactor this into smaller submethods? its much to large imho.

@FabioBatSilva
Copy link
Member Author

Hi.

Is done for me.

Please take a look and tell me if can I make something better or add another test case.

//cc @guilhermeblanco , @beberlei , @Ocramius , @asm89 .

}

if (isset($this->namedNativeQueries[$queryMapping['name']])) {
throw MappingException::duplicateQueryMapping($this->name, $queryMapping['name']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can actually bring to problems when Bundles/Modules define same native queries (like allUsers). I guess there's no solution for that...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Ocramius

Sorry I don't get this ...

The named native queries follows the same behavior of name queries.
A query name should be unique in a entity and could be override in a sub class..

please, could you explain ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FabioBatSilva maybe it's too much of an edge case :) No worries, just ignore it... Bundles extending other entities should be aware of what problems they're running in :)

@Ocramius
Copy link
Member

As @beberlei already pointed out, this uses advanced features, and it is not really intuitive... But it is an useful addition.

If I get it correctly, the suggested usage is to recycle named queries defined in the ClassMetadata instance through the EntityRepository API. Is that so?

Also, I'm a bit scared about how much the metadata drivers are growing in code size... Hopefully such additions won't appear too often :P (also remembers me that I have a WIP...)

@Ocramius
Copy link
Member

Also noting: feature is clear after some chatting on IRC. Not that clear from the code. Yeah, it's all internal stuff, but still a bit complex to grasp...

@beberlei
Copy link
Member

testing github 2 jira updates.

@beberlei
Copy link
Member

another test

guilhermeblanco added a commit that referenced this pull request Apr 16, 2012
[DDC-1663]Native SQL Query Result Set Mappings
@guilhermeblanco guilhermeblanco merged commit bad811d into doctrine:master Apr 16, 2012
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

Successfully merging this pull request may close these issues.

4 participants