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

Add support for querying by entity attributes (Trac #4215) #4215

Closed
elgg-gitbot opened this issue Feb 16, 2013 · 7 comments
Closed

Add support for querying by entity attributes (Trac #4215) #4215

elgg-gitbot opened this issue Feb 16, 2013 · 7 comments

Comments

@elgg-gitbot
Copy link

Original ticket http://trac.elgg.org/ticket/4215 on 41959403-06-21 by cash, assigned to unknown.

Elgg version: Github Master

  • user's username, email, display name
  • group's name, description
  • object's title, description

Would require a join to the appropriate type table and a where clause.

@elgg-gitbot
Copy link
Author

ewinslow wrote on 42365387-06-13

Some more options:

  • Move some of these attributes to the entities table. name/description are common for every entity type.
  • Move the attributes to metadata. The attributes are in their own table for performance reasons, but if we streamline metadata loading, this might be a non-issue.

@elgg-gitbot
Copy link
Author

Milestone changed to Long Term Future Release by ewinslow on 42365387-06-13

@elgg-gitbot
Copy link
Author

cash wrote on 42370249-04-18

Need to investigate adding a text field to every entity - what are the impacts to storage. Right now, I think every field in entity table is an int with fixed size.

@ghost
Copy link

ghost commented Feb 22, 2013

I needed to query by attributes and I found this (official) way on engine/lib/plugins.php elgg_get_plugin_from_id()

$options = array(
'type' => 'object',
'subtype' => 'plugin',
'joins' => array("JOIN {$db_prefix}objects_entity oe on oe.guid = e.guid"),
'wheres' => array("oe.title = '$plugin_id'"),
'limit' => 1
);

$plugins = elgg_get_entities($options);

It looks simple, I am thinking about including a function elgg_get_entites_from_attributes (similar to elgg_get_entities_from_metadata)

I have a concern about how to handle the four types of entities, because every entity has its own attributes. Maybe validating attributes depending on type or write functions for every type of entity (elgg_get_objects_from_attributes, elgg_get_sites_from_attributes). I want to know this in order to write correct implementation and where to put the functions.

@cash
Copy link
Contributor

cash commented Feb 22, 2013

I think elgg_get_entites_from_attributes() should only query against one type table so validating by type will work.

Unit tests should look something like this: https://github.com/Elgg/Elgg/blob/master/engine/tests/ElggCoreMetadataAPITest.php (see testElggGetEntitiesFromMetadata()).

@mrclay
Copy link
Member

mrclay commented Jul 3, 2013

This is probably obvious but we should not take on a schema change for 1.9.

@cash
Copy link
Contributor

cash commented Jul 3, 2013

Definitely obvious. This is just about adding elgg_get_entities_from_attributes().

@ghost ghost assigned cash Jul 3, 2013
@cash cash closed this as completed in f308203 Jul 13, 2013
cash added a commit that referenced this issue Jul 13, 2013
Fixes #4215 adds elgg_get_entities_from_attributes()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants