From 55fbef328f95e0a8dfff0a459c0bf9d24601a11a Mon Sep 17 00:00:00 2001 From: David Rothstein Date: Sun, 29 Jul 2012 23:35:26 -0400 Subject: Issue #1325628 by damien_vancouver, xjm, Damien Tournoud, TravisCarden | jbova: Fixed EntityFieldQuery::propertyQuery missing fully qualified column names causes ambiguous column DB error. --- modules/field/tests/field_test.module | 11 +++++++++++ modules/simpletest/tests/entity_query.test | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+) (limited to 'modules') diff --git a/modules/field/tests/field_test.module b/modules/field/tests/field_test.module index 0015cd905..37ea7b1dd 100644 --- a/modules/field/tests/field_test.module +++ b/modules/field/tests/field_test.module @@ -259,3 +259,14 @@ function field_test_field_widget_form_alter(&$element, &$form_state, $context) { break; } } + +/** + * Implements hook_query_TAG_alter() for tag 'efq_table_prefixing_test'. + * + * @see EntityFieldQueryTestCase::testTablePrefixing() + */ +function field_test_query_efq_table_prefixing_test_alter(&$query) { + // Add an additional join onto the entity base table. This will cause an + // exception if the EFQ does not properly prefix the base table. + $query->join('test_entity','te2','%alias.ftid = test_entity.ftid'); +} diff --git a/modules/simpletest/tests/entity_query.test b/modules/simpletest/tests/entity_query.test index 7a7c6222c..6d77c508b 100644 --- a/modules/simpletest/tests/entity_query.test +++ b/modules/simpletest/tests/entity_query.test @@ -1659,4 +1659,23 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase { $this->fail('Exception thrown: '. $e->getMessage()); } } + + /** + * Tests EFQ table prefixing with multiple conditions and an altered join. + * + * @see field_test_query_efq_table_prefixing_test_alter() + */ + function testTablePrefixing() { + $query = new EntityFieldQuery(); + $query = $query + ->entityCondition('entity_type', 'test_entity') + ->entityCondition('bundle', 'test_bundle') + ->entityCondition('entity_id', '1') + ->addTag('efq_table_prefixing_test'); + + $expected = array(array('test_entity', 1)); + + $this->assertEntityFieldQuery($query, $expected, 'An EntityFieldQuery returns the expected results when altered with an additional join on the base table.'); + } + } -- cgit v1.2.3