Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
b20cb1dd
Commit
b20cb1dd
authored
Nov 21, 2012
by
webchick
Browse files
Issue
#1837018
by yched: Fixed Possible 'ambiguous column name' error in field_read_fields().
parent
3be17a12
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/modules/field/field.crud.inc
View file @
b20cb1dd
...
...
@@ -354,6 +354,9 @@ function field_read_fields($params = array(), $include_additional = array()) {
}
$key
=
'fci.'
.
$key
;
}
else
{
$key
=
'fc.'
.
$key
;
}
$query
->
condition
(
$key
,
$value
);
}
...
...
core/modules/field/lib/Drupal/field/Tests/CrudTest.php
View file @
b20cb1dd
...
...
@@ -178,7 +178,7 @@ function testCreateFieldFail() {
}
/**
* Test reading
back a
field definition.
* Test
s
reading
a single
field definition.
*/
function
testReadField
()
{
$field_definition
=
array
(
...
...
@@ -192,6 +192,41 @@ function testReadField() {
$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.
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment