Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
drupal
Commits
9fb5187d
Commit
9fb5187d
authored
Jul 27, 2015
by
alexpott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2443679
followup by chx: PostgreSQL: Fix taxonomy\Tests\TermTest
parent
554f9a46
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
121 additions
and
84 deletions
+121
-84
core/core.services.yml
core/core.services.yml
+3
-0
core/lib/Drupal/Core/Database/Driver/mysql/EntityQuery/Condition.php
...upal/Core/Database/Driver/mysql/EntityQuery/Condition.php
+0
-22
core/lib/Drupal/Core/Database/Driver/sqlite/EntityQuery/Condition.php
...pal/Core/Database/Driver/sqlite/EntityQuery/Condition.php
+0
-22
core/lib/Drupal/Core/Database/EntityQuery/ConditionInterface.php
...b/Drupal/Core/Database/EntityQuery/ConditionInterface.php
+0
-30
core/lib/Drupal/Core/Database/Query/Select.php
core/lib/Drupal/Core/Database/Query/Select.php
+7
-0
core/lib/Drupal/Core/Database/Query/SelectExtender.php
core/lib/Drupal/Core/Database/Query/SelectExtender.php
+8
-0
core/lib/Drupal/Core/Database/Query/SelectInterface.php
core/lib/Drupal/Core/Database/Query/SelectInterface.php
+13
-0
core/lib/Drupal/Core/Entity/Query/ConditionFundamentals.php
core/lib/Drupal/Core/Entity/Query/ConditionFundamentals.php
+13
-1
core/lib/Drupal/Core/Entity/Query/Sql/Condition.php
core/lib/Drupal/Core/Entity/Query/Sql/Condition.php
+1
-7
core/lib/Drupal/Core/Entity/Query/Sql/ConditionAggregate.php
core/lib/Drupal/Core/Entity/Query/Sql/ConditionAggregate.php
+3
-1
core/lib/Drupal/Core/Entity/Query/Sql/QueryAggregate.php
core/lib/Drupal/Core/Entity/Query/Sql/QueryAggregate.php
+2
-1
core/lib/Drupal/Core/Entity/Query/Sql/pgsql/Condition.php
core/lib/Drupal/Core/Entity/Query/Sql/pgsql/Condition.php
+41
-0
core/lib/Drupal/Core/Entity/Query/Sql/pgsql/QueryFactory.php
core/lib/Drupal/Core/Entity/Query/Sql/pgsql/QueryFactory.php
+30
-0
No files found.
core/core.services.yml
View file @
9fb5187d
...
...
@@ -763,6 +763,9 @@ services:
arguments
:
[
'
@database'
]
tags
:
-
{
name
:
backend_overridable
}
pgsql.entity.query.sql
:
class
:
Drupal\Core\Entity\Query\Sql\pgsql\QueryFactory
arguments
:
[
'
@database'
]
entity.query.null
:
class
:
Drupal\Core\Entity\Query\Null\QueryFactory
entity.query.keyvalue
:
...
...
core/lib/Drupal/Core/Database/Driver/mysql/EntityQuery/Condition.php
deleted
100644 → 0
View file @
554f9a46
<?php
/**
* @file
* Contains Drupal\Core\Database\Driver\mysql\EntityQuery\Condition
*/
namespace
Drupal\Core\Database\Driver\mysql\EntityQuery
;
use
Drupal\Core\Database\EntityQuery\ConditionInterface
as
EntityQueryConditionInterface
;
/**
* Implements entity query conditions for SQL databases.
*/
class
Condition
implements
EntityQueryConditionInterface
{
/**
* {@inheritdoc}
*/
public
static
function
translateCondition
(
array
&
$condition
,
$case_sensitive
)
{
}
}
core/lib/Drupal/Core/Database/Driver/sqlite/EntityQuery/Condition.php
deleted
100644 → 0
View file @
554f9a46
<?php
/**
* @file
* Contains Drupal\Core\Database\Driver\sqlite\EntityQuery\Condition
*/
namespace
Drupal\Core\Database\Driver\sqlite\EntityQuery
;
use
Drupal\Core\Database\EntityQuery\ConditionInterface
as
EntityQueryConditionInterface
;
/**
* Implements entity query conditions for SQL databases.
*/
class
Condition
implements
EntityQueryConditionInterface
{
/**
* {@inheritdoc}
*/
public
static
function
translateCondition
(
array
&
$condition
,
$case_sensitive
)
{
}
}
core/lib/Drupal/Core/Database/EntityQuery/ConditionInterface.php
deleted
100644 → 0
View file @
554f9a46
<?php
/**
* @file
* Contains \Drupal\Core\Database\EntityQuery\ConditionInterface.
*/
namespace
Drupal\Core\Database\EntityQuery
;
/**
* Provides an interface for entity query conditions for SQL databases.
*/
interface
ConditionInterface
{
/**
* Translates the string operators to SQL equivalents. This is a no-op method
* for MySQL and SQLite databases but allows override if needed, e.g. for
* PostgreSQL to support case insensitive queries.
*
* @param array $condition
* The condition array.
* @param bool|null $case_sensitive
* If the condition should be case sensitive or not, NULL if the field does
* not define it.
*
* @see \Drupal\Core\Entity\Query\Sql\Condition::$entityQueryCondition
*/
public
static
function
translateCondition
(
array
&
$condition
,
$case_sensitive
);
}
core/lib/Drupal/Core/Database/Query/Select.php
View file @
9fb5187d
...
...
@@ -463,6 +463,13 @@ public function escapeLike($string) {
return
$this
->
connection
->
escapeLike
(
$string
);
}
/**
* {@inheritdoc}
*/
public
function
escapeField
(
$string
)
{
return
$this
->
connection
->
escapeField
(
$string
);
}
/**
* {@inheritdoc}
*/
...
...
core/lib/Drupal/Core/Database/Query/SelectExtender.php
View file @
9fb5187d
...
...
@@ -210,6 +210,14 @@ public function escapeLike($string) {
return
$this
->
query
->
escapeLike
(
$string
);
}
/**
* {@inheritdoc}
*/
public
function
escapeField
(
$string
)
{
$this
->
query
->
escapeField
(
$string
);
return
$this
;
}
public
function
getArguments
(
PlaceholderInterface
$queryPlaceholder
=
NULL
)
{
return
$this
->
query
->
getArguments
(
$queryPlaceholder
);
}
...
...
core/lib/Drupal/Core/Database/Query/SelectInterface.php
View file @
9fb5187d
...
...
@@ -140,6 +140,18 @@ public function &getUnion();
*/
public
function
escapeLike
(
$string
);
/**
* Escapes a field name string.
*
* Force all field names to be strictly alphanumeric-plus-underscore.
* For some database drivers, it may also wrap the field name in
* database-specific escape characters.
*
* @return
* The sanitized field name string.
*/
public
function
escapeField
(
$string
);
/**
* Compiles and returns an associative array of the arguments for this prepared statement.
*
...
...
@@ -632,4 +644,5 @@ public function __clone();
* The called object.
*/
public
function
forUpdate
(
$set
=
TRUE
);
}
core/lib/Drupal/Core/Entity/Query/ConditionFundamentals.php
View file @
9fb5187d
...
...
@@ -36,15 +36,27 @@ abstract class ConditionFundamentals {
*/
protected
$query
;
/**
* List of potential namespaces of the classes belonging to this condition.
*
* @var array
*/
protected
$namespaces
=
array
();
/**
* Constructs a Condition object.
*
* @param string $conjunction
* The operator to use to combine conditions: 'AND' or 'OR'.
* @param QueryInterface $query
* The entity query this condition belongs to.
* @param array $namespaces
* List of potential namespaces of the classes belonging to this condition.
*/
public
function
__construct
(
$conjunction
,
QueryInterface
$query
)
{
public
function
__construct
(
$conjunction
,
QueryInterface
$query
,
$namespaces
=
[]
)
{
$this
->
conjunction
=
$conjunction
;
$this
->
query
=
$query
;
$this
->
namespaces
=
$namespaces
;
}
/**
...
...
core/lib/Drupal/Core/Entity/Query/Sql/Condition.php
View file @
9fb5187d
...
...
@@ -7,7 +7,6 @@
namespace
Drupal\Core\Entity\Query\Sql
;
use
Drupal\Core\Database\Database
;
use
Drupal\Core\Database\Query\SelectInterface
;
use
Drupal\Core\Database\Query\Condition
as
SqlCondition
;
use
Drupal\Core\Entity\Query\ConditionBase
;
...
...
@@ -90,13 +89,8 @@ public function notExists($field, $langcode = NULL) {
* @see \Drupal\Core\Database\Query\ConditionInterface::condition()
*/
public
static
function
translateCondition
(
&
$condition
,
SelectInterface
$sql_query
,
$case_sensitive
)
{
// There is nothing to do for IN () queries except for PostgreSQL for which
// the condition arguments need to have case lowered to support not case
// sensitive fields.
// // There is nothing we can do for IN ().
if
(
is_array
(
$condition
[
'value'
]))
{
$entityQueryCondition
=
Database
::
getConnection
()
->
getDriverClass
(
'EntityQuery\\Condition'
);
$entityQueryCondition
::
translateCondition
(
$condition
,
$case_sensitive
);
return
;
}
...
...
core/lib/Drupal/Core/Entity/Query/Sql/ConditionAggregate.php
View file @
9fb5187d
...
...
@@ -11,6 +11,7 @@
use
Drupal\Core\Entity\Query\ConditionAggregateBase
;
use
Drupal\Core\Entity\Query\ConditionAggregateInterface
;
use
Drupal\Core\Database\Query\Condition
as
SqlCondition
;
use
Drupal\Core\Entity\Query\QueryBase
;
/**
* Defines the aggregate condition for sql based storage.
...
...
@@ -39,7 +40,8 @@ public function compile($conditionContainer) {
else
{
$type
=
((
strtoupper
(
$this
->
conjunction
)
==
'OR'
)
||
(
$condition
[
'operator'
]
==
'IS NULL'
))
?
'LEFT'
:
'INNER'
;
$field
=
$tables
->
addField
(
$condition
[
'field'
],
$type
,
$condition
[
'langcode'
]);
Condition
::
translateCondition
(
$condition
,
$sql_query
,
$tables
->
isFieldCaseSensitive
(
$condition
[
'field'
]));
$condition_class
=
QueryBase
::
getClass
(
$this
->
namespaces
,
'Condition'
);
$condition_class
::
translateCondition
(
$condition
,
$sql_query
,
$tables
->
isFieldCaseSensitive
(
$condition
[
'field'
]));
$function
=
$condition
[
'function'
];
$placeholder
=
':db_placeholder_'
.
$conditionContainer
->
nextPlaceholder
();
$conditionContainer
->
having
(
"
$function
(
$field
)
{
$condition
[
'operator'
]
}
$placeholder
"
,
array
(
$placeholder
=>
$condition
[
'value'
]));
...
...
core/lib/Drupal/Core/Entity/Query/Sql/QueryAggregate.php
View file @
9fb5187d
...
...
@@ -52,7 +52,8 @@ public function prepare() {
* Implements \Drupal\Core\Entity\Query\QueryAggregateInterface::conditionAggregateGroupFactory().
*/
public
function
conditionAggregateGroupFactory
(
$conjunction
=
'AND'
)
{
return
new
ConditionAggregate
(
$conjunction
,
$this
);
$class
=
static
::
getClass
(
$this
->
namespaces
,
'ConditionAggregate'
);
return
new
$class
(
$conjunction
,
$this
,
$this
->
namespaces
);
}
/**
...
...
core/lib/Drupal/Core/
Database/Driver/pgsql/
EntityQuery/Condition.php
→
core/lib/Drupal/Core/Entity
/
Query/
Sql/pgsql/
Condition.php
View file @
9fb5187d
...
...
@@ -2,29 +2,25 @@
/**
* @file
* Contains Drupal\Core\
Database\Driver\pgsql\
EntityQuery\Condition
* Contains
\
Drupal\Core\Entity
\
Query\
Sql\pgsql\
Condition
.
*/
namespace
Drupal\Core\
Database\Driver\pgsql\
EntityQuery
;
namespace
Drupal\Core\Entity
\
Query
\Sql\pgsql
;
use
Drupal\Core\Database\
Databas
e
;
use
Drupal\Core\
Database\
EntityQuery\Condition
Interface
as
EntityQueryConditionInterface
;
use
Drupal\Core\Database\
Query\SelectInterfac
e
;
use
Drupal\Core\Entity
\
Query\
Sql\
Condition
as
BaseCondition
;
/**
* Implements entity query conditions for SQL databases.
* Implements entity query conditions for
Postgre
SQL databases.
*/
class
Condition
implem
en
t
s
EntityQueryConditionInterface
{
class
Condition
ext
en
d
s
BaseCondition
{
/**
* {@inheritdoc}
*/
public
static
function
translateCondition
(
array
&
$condition
,
$case_sensitive
)
{
$connection
=
Database
::
getConnection
();
// For PostgreSQL all the condition arguments need to have case
// lowered to support not case sensitive fields.
public
static
function
translateCondition
(
&
$condition
,
SelectInterface
$sql_query
,
$case_sensitive
)
{
if
(
is_array
(
$condition
[
'value'
])
&&
$case_sensitive
===
FALSE
)
{
$condition
[
'where'
]
=
'LOWER('
.
$
connection
->
escapeField
(
$condition
[
'real_field'
])
.
') '
.
$condition
[
'operator'
]
.
' ('
;
$condition
[
'where'
]
=
'LOWER('
.
$
sql_query
->
escapeField
(
$condition
[
'real_field'
])
.
') '
.
$condition
[
'operator'
]
.
' ('
;
$condition
[
'where_args'
]
=
[];
$n
=
1
;
...
...
@@ -38,7 +34,8 @@ public static function translateCondition(array &$condition, $case_sensitive) {
}
$condition
[
'where'
]
=
trim
(
$condition
[
'where'
],
','
);
$condition
[
'where'
]
.
=
')'
;
return
;
}
parent
::
translateCondition
(
$condition
,
$sql_query
,
$case_sensitive
);
}
}
core/lib/Drupal/Core/Entity/Query/Sql/pgsql/QueryFactory.php
0 → 100644
View file @
9fb5187d
<?php
/**
* @file
* Contains \Drupal\Core\Entity\Query\Sql\pgsql\QueryFactory.
*/
namespace
Drupal\Core\Entity\Query\Sql\pgsql
;
use
Drupal\Core\Entity\Query\Sql\QueryFactory
as
BaseQueryFactory
;
/**
* PostgreSQL specific entity query implementation.
*
* To add a new query implementation extending the default SQL one, add
* a service definition like pgsql.entity.query.sql and a factory class like
* this. The system will automatically find the relevant Query, QueryAggregate,
* Condition, ConditionAggregate, Tables classes in this namespace, in the
* namespace of the parent class and so on. So after creating an empty query
* factory class like this, it is possible to just drop in a class extending
* the base class in this namespace and it will be used automatically but it
* is optional: if a class is not extended the relevant default is used.
*
* @see \Drupal\Core\Entity\Query\QueryBase::getNamespaces()
* @see \Drupal\Core\Entity\Query\QueryBase::getClass()
*/
class
QueryFactory
extends
BaseQueryFactory
{
}
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