Issue #1837018 by yched: Fixed Possible 'ambiguous column name' error in field_read_fields().
parent
3be17a12bf
commit
b20cb1dd19
|
@ -354,6 +354,9 @@ function field_read_fields($params = array(), $include_additional = array()) {
|
|||
}
|
||||
$key = 'fci.' . $key;
|
||||
}
|
||||
else {
|
||||
$key = 'fc.' . $key;
|
||||
}
|
||||
|
||||
$query->condition($key, $value);
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ class CrudTest extends FieldTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test reading back a field definition.
|
||||
* Tests reading a single field definition.
|
||||
*/
|
||||
function testReadField() {
|
||||
$field_definition = array(
|
||||
|
@ -192,6 +192,41 @@ class CrudTest extends FieldTestBase {
|
|||
$this->assertTrue($field_definition < $field, 'The field was properly read.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests reading field definitions.
|
||||
*/
|
||||
function testReadFields() {
|
||||
$field_definition = array(
|
||||
'field_name' => 'field_1',
|
||||
'type' => 'test_field',
|
||||
);
|
||||
field_create_field($field_definition);
|
||||
|
||||
// Check that 'single column' criteria works.
|
||||
$fields = field_read_fields(array('field_name' => $field_definition['field_name']));
|
||||
$this->assertTrue(count($fields) == 1 && isset($fields[$field_definition['field_name']]), 'The field was properly read.');
|
||||
|
||||
// Check that 'multi column' criteria works.
|
||||
$fields = field_read_fields(array('field_name' => $field_definition['field_name'], 'type' => $field_definition['type']));
|
||||
$this->assertTrue(count($fields) == 1 && isset($fields[$field_definition['field_name']]), 'The field was properly read.');
|
||||
$fields = field_read_fields(array('field_name' => $field_definition['field_name'], 'type' => 'foo'));
|
||||
$this->assertTrue(empty($fields), 'No field was found.');
|
||||
|
||||
// Create an instance of the field.
|
||||
$instance_definition = array(
|
||||
'field_name' => $field_definition['field_name'],
|
||||
'entity_type' => 'test_entity',
|
||||
'bundle' => 'test_bundle',
|
||||
);
|
||||
field_create_instance($instance_definition);
|
||||
|
||||
// Check that criteria spanning over the field_config_instance table work.
|
||||
$fields = field_read_fields(array('entity_type' => $instance_definition['entity_type'], 'bundle' => $instance_definition['bundle']));
|
||||
$this->assertTrue(count($fields) == 1 && isset($fields[$field_definition['field_name']]), 'The field was properly read.');
|
||||
$fields = field_read_fields(array('entity_type' => $instance_definition['entity_type'], 'field_name' => $instance_definition['field_name']));
|
||||
$this->assertTrue(count($fields) == 1 && isset($fields[$field_definition['field_name']]), 'The field was properly read.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test creation of indexes on data column.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue