Skip to content

Commit

Permalink
Do not prefix database when using SQLite
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterj committed Mar 1, 2015
1 parent e9f7703 commit b72a8f9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions src/Kunstmaan/AdminBundle/Helper/Security/Acl/AclHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ public function apply(QueryBuilder $queryBuilder, PermissionDefinition $permissi
*/
private function getPermittedAclIdsSQLForUser(Query $query)
{
$aclConnection = $this->em->getConnection();
$database = $aclConnection->getDatabase();
$mask = $query->getHint('acl.mask');
$rootEntity = '"' . str_replace('\\', '\\\\', $query->getHint('acl.root.entity')) . '"';
$aclConnection = $this->em->getConnection();
$databasePrefix = is_file($aclConnection->getDatabase()) ? '' : $aclConnection->getDatabase().'.';
$mask = $query->getHint('acl.mask');
$rootEntity = '"' . str_replace('\\', '\\\\', $query->getHint('acl.root.entity')) . '"';

/* @var $token TokenInterface */
$token = $this->securityContext->getToken();
Expand Down Expand Up @@ -175,13 +175,13 @@ private function getPermittedAclIdsSQLForUser(Query $query)
}

$selectQuery = <<<SELECTQUERY
SELECT DISTINCT o.object_identifier as id FROM {$database}.acl_object_identities as o
INNER JOIN {$database}.acl_classes c ON c.id = o.class_id
LEFT JOIN {$database}.acl_entries e ON (
SELECT DISTINCT o.object_identifier as id FROM {$databasePrefix}acl_object_identities as o
INNER JOIN {$databasePrefix}acl_classes c ON c.id = o.class_id
LEFT JOIN {$databasePrefix}acl_entries e ON (
e.class_id = o.class_id AND (e.object_identity_id = o.id
OR {$aclConnection->getDatabasePlatform()->getIsNullExpression('e.object_identity_id')})
)
LEFT JOIN {$database}.acl_security_identities s ON (
LEFT JOIN {$databasePrefix}acl_security_identities s ON (
s.id = e.security_identity_id
)
WHERE c.class_type = {$rootEntity}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public function apply(QueryBuilder $queryBuilder, PermissionDefinition $permissi
{
$aclConnection = $this->em->getConnection();

$database = $aclConnection->getDatabase();
$rootEntity = $permissionDef->getEntity();
$linkAlias = $permissionDef->getAlias();
$databasePrefix = is_file($aclConnection->getDatabase()) ? '' : $aclConnection->getDatabase().'.';
$rootEntity = $permissionDef->getEntity();
$linkAlias = $permissionDef->getAlias();
// Only tables with a single ID PK are currently supported
$linkField = $this->em->getClassMetadata($rootEntity)->getSingleIdentifierColumnName();
$linkField = $this->em->getClassMetadata($rootEntity)->getSingleIdentifierColumnName();

$rootEntity = '"' . str_replace('\\', '\\\\', $rootEntity) . '"';
$query = $queryBuilder;
Expand Down Expand Up @@ -107,13 +107,13 @@ public function apply(QueryBuilder $queryBuilder, PermissionDefinition $permissi
}

$joinTableQuery = <<<SELECTQUERY
SELECT DISTINCT o.object_identifier as id FROM {$database}.acl_object_identities as o
INNER JOIN {$database}.acl_classes c ON c.id = o.class_id
LEFT JOIN {$database}.acl_entries e ON (
SELECT DISTINCT o.object_identifier as id FROM {$databasePrefix}.acl_object_identities as o
INNER JOIN {$databasePrefix}.acl_classes c ON c.id = o.class_id
LEFT JOIN {$databasePrefix}.acl_entries e ON (
e.class_id = o.class_id AND (e.object_identity_id = o.id
OR {$aclConnection->getDatabasePlatform()->getIsNullExpression('e.object_identity_id')})
)
LEFT JOIN {$database}.acl_security_identities s ON (
LEFT JOIN {$databasePrefix}.acl_security_identities s ON (
s.id = e.security_identity_id
)
WHERE c.class_type = {$rootEntity}
Expand Down

0 comments on commit b72a8f9

Please sign in to comment.