Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
9e2a9a40
Unverified
Commit
9e2a9a40
authored
May 29, 2019
by
Jonathan H. Wage
Committed by
Sergei Morozov
Nov 02, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add proper types to the Doctrine\DBAL\Sharding namespace.
parent
f90c5001
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
63 deletions
+30
-63
PoolingShardManager.php
lib/Doctrine/DBAL/Sharding/PoolingShardManager.php
+5
-5
SQLAzureFederationsSynchronizer.php
...BAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php
+5
-15
SQLAzureShardManager.php
lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php
+11
-23
MultiTenantVisitor.php
...rine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php
+3
-9
ShardManager.php
lib/Doctrine/DBAL/Sharding/ShardManager.php
+6
-11
No files found.
lib/Doctrine/DBAL/Sharding/PoolingShardManager.php
View file @
9e2a9a40
...
@@ -18,7 +18,7 @@ class PoolingShardManager implements ShardManager
...
@@ -18,7 +18,7 @@ class PoolingShardManager implements ShardManager
/** @var ShardChoser */
/** @var ShardChoser */
private
$choser
;
private
$choser
;
/** @var
string|null
*/
/** @var
mixed
*/
private
$currentDistributionValue
;
private
$currentDistributionValue
;
public
function
__construct
(
PoolingShardConnection
$conn
)
public
function
__construct
(
PoolingShardConnection
$conn
)
...
@@ -31,7 +31,7 @@ class PoolingShardManager implements ShardManager
...
@@ -31,7 +31,7 @@ class PoolingShardManager implements ShardManager
/**
/**
* {@inheritDoc}
* {@inheritDoc}
*/
*/
public
function
selectGlobal
()
public
function
selectGlobal
()
:
void
{
{
$this
->
conn
->
connect
(
0
);
$this
->
conn
->
connect
(
0
);
$this
->
currentDistributionValue
=
null
;
$this
->
currentDistributionValue
=
null
;
...
@@ -40,7 +40,7 @@ class PoolingShardManager implements ShardManager
...
@@ -40,7 +40,7 @@ class PoolingShardManager implements ShardManager
/**
/**
* {@inheritDoc}
* {@inheritDoc}
*/
*/
public
function
selectShard
(
$distributionValue
)
public
function
selectShard
(
$distributionValue
)
:
void
{
{
$shardId
=
$this
->
choser
->
pickShard
(
$distributionValue
,
$this
->
conn
);
$shardId
=
$this
->
choser
->
pickShard
(
$distributionValue
,
$this
->
conn
);
$this
->
conn
->
connect
(
$shardId
);
$this
->
conn
->
connect
(
$shardId
);
...
@@ -58,7 +58,7 @@ class PoolingShardManager implements ShardManager
...
@@ -58,7 +58,7 @@ class PoolingShardManager implements ShardManager
/**
/**
* {@inheritDoc}
* {@inheritDoc}
*/
*/
public
function
getShards
()
public
function
getShards
()
:
array
{
{
$params
=
$this
->
conn
->
getParams
();
$params
=
$this
->
conn
->
getParams
();
$shards
=
[];
$shards
=
[];
...
@@ -75,7 +75,7 @@ class PoolingShardManager implements ShardManager
...
@@ -75,7 +75,7 @@ class PoolingShardManager implements ShardManager
*
*
* @throws RuntimeException
* @throws RuntimeException
*/
*/
public
function
queryAll
(
$sql
,
array
$params
,
array
$types
)
public
function
queryAll
(
string
$sql
,
array
$params
,
array
$types
)
:
array
{
{
$shards
=
$this
->
getShards
();
$shards
=
$this
->
getShards
();
if
(
!
$shards
)
{
if
(
!
$shards
)
{
...
...
lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php
View file @
9e2a9a40
...
@@ -158,7 +158,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
...
@@ -158,7 +158,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
/**
/**
* @return Schema[]
* @return Schema[]
*/
*/
private
function
partitionSchema
(
Schema
$schema
)
private
function
partitionSchema
(
Schema
$schema
)
:
array
{
{
return
[
return
[
$this
->
extractSchemaFederation
(
$schema
,
false
),
$this
->
extractSchemaFederation
(
$schema
,
false
),
...
@@ -167,13 +167,9 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
...
@@ -167,13 +167,9 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
}
}
/**
/**
* @param bool $isFederation
*
* @return Schema
*
* @throws RuntimeException
* @throws RuntimeException
*/
*/
private
function
extractSchemaFederation
(
Schema
$schema
,
$isFederation
)
private
function
extractSchemaFederation
(
Schema
$schema
,
bool
$isFederation
)
:
Schema
{
{
$partitionedSchema
=
clone
$schema
;
$partitionedSchema
=
clone
$schema
;
...
@@ -204,7 +200,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
...
@@ -204,7 +200,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
*
*
* @return string[]
* @return string[]
*/
*/
private
function
work
(
Schema
$schema
,
Closure
$operation
)
private
function
work
(
Schema
$schema
,
Closure
$operation
)
:
array
{
{
[
$global
,
$federation
]
=
$this
->
partitionSchema
(
$schema
);
[
$global
,
$federation
]
=
$this
->
partitionSchema
(
$schema
);
$sql
=
[];
$sql
=
[];
...
@@ -235,10 +231,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
...
@@ -235,10 +231,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
return
$sql
;
return
$sql
;
}
}
/**
private
function
getFederationTypeDefaultValue
()
:
string
* @return string
*/
private
function
getFederationTypeDefaultValue
()
{
{
$federationType
=
Type
::
getType
(
$this
->
shardManager
->
getDistributionType
());
$federationType
=
Type
::
getType
(
$this
->
shardManager
->
getDistributionType
());
...
@@ -259,10 +252,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
...
@@ -259,10 +252,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
return
$defaultValue
;
return
$defaultValue
;
}
}
/**
private
function
getCreateFederationStatement
()
:
string
* @return string
*/
private
function
getCreateFederationStatement
()
{
{
$federationType
=
Type
::
getType
(
$this
->
shardManager
->
getDistributionType
());
$federationType
=
Type
::
getType
(
$this
->
shardManager
->
getDistributionType
());
$federationTypeSql
=
$federationType
->
getSQLDeclaration
([],
$this
->
conn
->
getDatabasePlatform
());
$federationTypeSql
=
$federationType
->
getSQLDeclaration
([],
$this
->
conn
->
getDatabasePlatform
());
...
...
lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php
View file @
9e2a9a40
...
@@ -35,7 +35,7 @@ class SQLAzureShardManager implements ShardManager
...
@@ -35,7 +35,7 @@ class SQLAzureShardManager implements ShardManager
/** @var Connection */
/** @var Connection */
private
$conn
;
private
$conn
;
/** @var
string|null
*/
/** @var
mixed
*/
private
$currentDistributionValue
;
private
$currentDistributionValue
;
/**
/**
...
@@ -66,50 +66,40 @@ class SQLAzureShardManager implements ShardManager
...
@@ -66,50 +66,40 @@ class SQLAzureShardManager implements ShardManager
/**
/**
* Gets the name of the federation.
* Gets the name of the federation.
*
* @return string
*/
*/
public
function
getFederationName
()
public
function
getFederationName
()
:
string
{
{
return
$this
->
federationName
;
return
$this
->
federationName
;
}
}
/**
/**
* Gets the distribution key.
* Gets the distribution key.
*
* @return string
*/
*/
public
function
getDistributionKey
()
public
function
getDistributionKey
()
:
string
{
{
return
$this
->
distributionKey
;
return
$this
->
distributionKey
;
}
}
/**
/**
* Gets the Doctrine Type name used for the distribution.
* Gets the Doctrine Type name used for the distribution.
*
* @return string
*/
*/
public
function
getDistributionType
()
public
function
getDistributionType
()
:
string
{
{
return
$this
->
distributionType
;
return
$this
->
distributionType
;
}
}
/**
/**
* Sets Enabled/Disable filtering on the fly.
* Sets Enabled/Disable filtering on the fly.
*
* @param bool $flag
*
* @return void
*/
*/
public
function
setFilteringEnabled
(
$flag
)
public
function
setFilteringEnabled
(
bool
$flag
)
:
void
{
{
$this
->
filteringEnabled
=
(
bool
)
$flag
;
$this
->
filteringEnabled
=
$flag
;
}
}
/**
/**
* {@inheritDoc}
* {@inheritDoc}
*/
*/
public
function
selectGlobal
()
public
function
selectGlobal
()
:
void
{
{
if
(
$this
->
conn
->
isTransactionActive
())
{
if
(
$this
->
conn
->
isTransactionActive
())
{
throw
ActiveTransaction
::
new
();
throw
ActiveTransaction
::
new
();
...
@@ -123,7 +113,7 @@ class SQLAzureShardManager implements ShardManager
...
@@ -123,7 +113,7 @@ class SQLAzureShardManager implements ShardManager
/**
/**
* {@inheritDoc}
* {@inheritDoc}
*/
*/
public
function
selectShard
(
$distributionValue
)
public
function
selectShard
(
$distributionValue
)
:
void
{
{
if
(
$this
->
conn
->
isTransactionActive
())
{
if
(
$this
->
conn
->
isTransactionActive
())
{
throw
ActiveTransaction
::
new
();
throw
ActiveTransaction
::
new
();
...
@@ -153,7 +143,7 @@ class SQLAzureShardManager implements ShardManager
...
@@ -153,7 +143,7 @@ class SQLAzureShardManager implements ShardManager
/**
/**
* {@inheritDoc}
* {@inheritDoc}
*/
*/
public
function
getShards
()
public
function
getShards
()
:
array
{
{
$sql
=
'SELECT member_id as id,
$sql
=
'SELECT member_id as id,
distribution_name as distribution_key,
distribution_name as distribution_key,
...
@@ -169,7 +159,7 @@ class SQLAzureShardManager implements ShardManager
...
@@ -169,7 +159,7 @@ class SQLAzureShardManager implements ShardManager
/**
/**
* {@inheritDoc}
* {@inheritDoc}
*/
*/
public
function
queryAll
(
$sql
,
array
$params
=
[],
array
$types
=
[])
public
function
queryAll
(
string
$sql
,
array
$params
=
[],
array
$types
=
[])
:
array
{
{
$shards
=
$this
->
getShards
();
$shards
=
$this
->
getShards
();
if
(
!
$shards
)
{
if
(
!
$shards
)
{
...
@@ -199,10 +189,8 @@ class SQLAzureShardManager implements ShardManager
...
@@ -199,10 +189,8 @@ class SQLAzureShardManager implements ShardManager
* Splits Federation at a given distribution value.
* Splits Federation at a given distribution value.
*
*
* @param mixed $splitDistributionValue
* @param mixed $splitDistributionValue
*
* @return void
*/
*/
public
function
splitFederation
(
$splitDistributionValue
)
public
function
splitFederation
(
$splitDistributionValue
)
:
void
{
{
$type
=
Type
::
getType
(
$this
->
distributionType
);
$type
=
Type
::
getType
(
$this
->
distributionType
);
...
...
lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php
View file @
9e2a9a40
...
@@ -55,10 +55,8 @@ class MultiTenantVisitor implements Visitor
...
@@ -55,10 +55,8 @@ class MultiTenantVisitor implements Visitor
/**
/**
* @param string[] $excludedTables
* @param string[] $excludedTables
* @param string $tenantColumnName
* @param string|null $distributionName
*/
*/
public
function
__construct
(
array
$excludedTables
=
[],
$tenantColumnName
=
'tenant_id'
,
$distributionName
=
null
)
public
function
__construct
(
array
$excludedTables
=
[],
string
$tenantColumnName
=
'tenant_id'
,
?
string
$distributionName
=
null
)
{
{
$this
->
excludedTables
=
$excludedTables
;
$this
->
excludedTables
=
$excludedTables
;
$this
->
tenantColumnName
=
$tenantColumnName
;
$this
->
tenantColumnName
=
$tenantColumnName
;
...
@@ -94,13 +92,9 @@ class MultiTenantVisitor implements Visitor
...
@@ -94,13 +92,9 @@ class MultiTenantVisitor implements Visitor
}
}
/**
/**
* @param Table $table
*
* @return Index
*
* @throws RuntimeException
* @throws RuntimeException
*/
*/
private
function
getClusteredIndex
(
$table
)
private
function
getClusteredIndex
(
Table
$table
)
:
Index
{
{
foreach
(
$table
->
getIndexes
()
as
$index
)
{
foreach
(
$table
->
getIndexes
()
as
$index
)
{
if
(
$index
->
isPrimary
()
&&
!
$index
->
hasFlag
(
'nonclustered'
))
{
if
(
$index
->
isPrimary
()
&&
!
$index
->
hasFlag
(
'nonclustered'
))
{
...
...
lib/Doctrine/DBAL/Sharding/ShardManager.php
View file @
9e2a9a40
...
@@ -27,26 +27,22 @@ interface ShardManager
...
@@ -27,26 +27,22 @@ interface ShardManager
*
*
* This is the default database that is connected when no shard is
* This is the default database that is connected when no shard is
* selected.
* selected.
*
* @return void
*/
*/
public
function
selectGlobal
();
public
function
selectGlobal
()
:
void
;
/**
/**
* Selects the shard against which the queries after this statement will be issued.
* Selects the shard against which the queries after this statement will be issued.
*
*
* @param string $distributionValue
* @param mixed $distributionValue
*
* @return void
*
*
* @throws ShardingException If no value is passed as shard identifier.
* @throws ShardingException If no value is passed as shard identifier.
*/
*/
public
function
selectShard
(
$distributionValue
);
public
function
selectShard
(
$distributionValue
)
:
void
;
/**
/**
* Gets the distribution value currently used for sharding.
* Gets the distribution value currently used for sharding.
*
*
* @return
string|null
* @return
mixed
*/
*/
public
function
getCurrentDistributionValue
();
public
function
getCurrentDistributionValue
();
...
@@ -58,7 +54,7 @@ interface ShardManager
...
@@ -58,7 +54,7 @@ interface ShardManager
*
*
* @return mixed[][]
* @return mixed[][]
*/
*/
public
function
getShards
();
public
function
getShards
()
:
array
;
/**
/**
* Queries all shards in undefined order and return the results appended to
* Queries all shards in undefined order and return the results appended to
...
@@ -66,11 +62,10 @@ interface ShardManager
...
@@ -66,11 +62,10 @@ interface ShardManager
*
*
* Using {@link \Doctrine\DBAL\Connection::fetchAll} to retrieve rows internally.
* Using {@link \Doctrine\DBAL\Connection::fetchAll} to retrieve rows internally.
*
*
* @param string $sql
* @param mixed[] $params
* @param mixed[] $params
* @param int[]|string[] $types
* @param int[]|string[] $types
*
*
* @return mixed[]
* @return mixed[]
*/
*/
public
function
queryAll
(
$sql
,
array
$params
,
array
$types
)
;
public
function
queryAll
(
string
$sql
,
array
$params
,
array
$types
)
:
array
;
}
}
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