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
75bf53d7
Unverified
Commit
75bf53d7
authored
Jun 04, 2019
by
Jonathan H. Wage
Committed by
Sergei Morozov
Nov 02, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3583 from morozov/event-types-cleanup
Getting rid of the column name index
parents
d04026ff
81c9d601
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
27 deletions
+44
-27
UPGRADE.md
UPGRADE.md
+4
-0
SchemaCreateTableEventArgs.php
lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php
+6
-5
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+9
-12
OraclePlatform.php
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
+3
-4
SqlitePlatform.php
lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
+4
-2
TemporaryTableTest.php
tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php
+18
-4
No files found.
UPGRADE.md
View file @
75bf53d7
# Upgrade to 3.0
# Upgrade to 3.0
## BC BREAK: Changes in `Doctrine\DBAL\Event\SchemaCreateTableEventArgs`
Table columns are no longer indexed by column name. Use the
`name`
attribute of the column instead.
## BC BREAK: Changes in the `Doctrine\DBAL\Schema` API
## BC BREAK: Changes in the `Doctrine\DBAL\Schema` API
-
Column precision no longer defaults to 10. The default value is NULL.
-
Column precision no longer defaults to 10. The default value is NULL.
...
...
lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php
View file @
75bf53d7
...
@@ -9,14 +9,15 @@ use Doctrine\DBAL\Schema\Table;
...
@@ -9,14 +9,15 @@ use Doctrine\DBAL\Schema\Table;
use
function
array_merge
;
use
function
array_merge
;
/**
/**
* Event Arguments used when SQL queries for creating tables are generated inside Doctrine\DBAL\Platform\AbstractPlatform.
* Event Arguments used when SQL queries for creating tables are generated
* inside Doctrine\DBAL\Platform\AbstractPlatform.
*/
*/
class
SchemaCreateTableEventArgs
extends
SchemaEventArgs
class
SchemaCreateTableEventArgs
extends
SchemaEventArgs
{
{
/** @var Table */
/** @var Table */
private
$table
;
private
$table
;
/** @var array<
string
, array<string, mixed>> */
/** @var array<
int
, array<string, mixed>> */
private
$columns
;
private
$columns
;
/** @var array<string, mixed> */
/** @var array<string, mixed> */
...
@@ -29,8 +30,8 @@ class SchemaCreateTableEventArgs extends SchemaEventArgs
...
@@ -29,8 +30,8 @@ class SchemaCreateTableEventArgs extends SchemaEventArgs
private
$sql
=
[];
private
$sql
=
[];
/**
/**
* @param array<
string
, array<string, mixed>> $columns
* @param array<
int
, array<string, mixed>> $columns
* @param array<string, mixed>
$options
* @param array<string, mixed> $options
*/
*/
public
function
__construct
(
Table
$table
,
array
$columns
,
array
$options
,
AbstractPlatform
$platform
)
public
function
__construct
(
Table
$table
,
array
$columns
,
array
$options
,
AbstractPlatform
$platform
)
{
{
...
@@ -46,7 +47,7 @@ class SchemaCreateTableEventArgs extends SchemaEventArgs
...
@@ -46,7 +47,7 @@ class SchemaCreateTableEventArgs extends SchemaEventArgs
}
}
/**
/**
* @return array<
string
, array<string, mixed>>
* @return array<
int
, array<string, mixed>>
*/
*/
public
function
getColumns
()
:
array
public
function
getColumns
()
:
array
{
{
...
...
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
75bf53d7
...
@@ -1345,10 +1345,7 @@ abstract class AbstractPlatform
...
@@ -1345,10 +1345,7 @@ abstract class AbstractPlatform
$columnData
[
'primary'
]
=
true
;
$columnData
[
'primary'
]
=
true
;
}
}
$columnName
=
$columnData
[
'name'
];
$columns
[]
=
$columnData
;
assert
(
is_string
(
$columnName
));
$columns
[
$columnName
]
=
$columnData
;
}
}
if
(
$this
->
_eventManager
!==
null
&&
$this
->
_eventManager
->
hasListeners
(
Events
::
onSchemaCreateTable
))
{
if
(
$this
->
_eventManager
!==
null
&&
$this
->
_eventManager
->
hasListeners
(
Events
::
onSchemaCreateTable
))
{
...
@@ -1875,9 +1872,9 @@ abstract class AbstractPlatform
...
@@ -1875,9 +1872,9 @@ abstract class AbstractPlatform
/**
/**
* Gets declaration of a number of fields in bulk.
* Gets declaration of a number of fields in bulk.
*
*
* @param mixed[][] $fields A multidimensional a
ssociative a
rray.
* @param mixed[][] $fields A multidimensional array.
* The first dimension determines the
field name, while the second
* The first dimension determines the
ordinal position of the field,
* dimension is keyed with the name of the properties
*
while the second
dimension is keyed with the name of the properties
* of the field being declared as array indexes. Currently, the types
* of the field being declared as array indexes. Currently, the types
* of supported field properties are as follows:
* of supported field properties are as follows:
*
*
...
@@ -1903,8 +1900,8 @@ abstract class AbstractPlatform
...
@@ -1903,8 +1900,8 @@ abstract class AbstractPlatform
{
{
$queryFields
=
[];
$queryFields
=
[];
foreach
(
$fields
as
$field
Name
=>
$field
)
{
foreach
(
$fields
as
$field
)
{
$queryFields
[]
=
$this
->
getColumnDeclarationSQL
(
$field
Name
,
$field
);
$queryFields
[]
=
$this
->
getColumnDeclarationSQL
(
$field
[
'name'
]
,
$field
);
}
}
return
implode
(
', '
,
$queryFields
);
return
implode
(
', '
,
$queryFields
);
...
@@ -2050,19 +2047,19 @@ abstract class AbstractPlatform
...
@@ -2050,19 +2047,19 @@ abstract class AbstractPlatform
public
function
getCheckDeclarationSQL
(
array
$definition
)
:
string
public
function
getCheckDeclarationSQL
(
array
$definition
)
:
string
{
{
$constraints
=
[];
$constraints
=
[];
foreach
(
$definition
as
$
field
=>
$
def
)
{
foreach
(
$definition
as
$def
)
{
if
(
is_string
(
$def
))
{
if
(
is_string
(
$def
))
{
$constraints
[]
=
'CHECK ('
.
$def
.
')'
;
$constraints
[]
=
'CHECK ('
.
$def
.
')'
;
}
else
{
}
else
{
if
(
isset
(
$def
[
'min'
]))
{
if
(
isset
(
$def
[
'min'
]))
{
$constraints
[]
=
'CHECK ('
.
$
field
.
' >= '
.
$def
[
'min'
]
.
')'
;
$constraints
[]
=
'CHECK ('
.
$
def
[
'name'
]
.
' >= '
.
$def
[
'min'
]
.
')'
;
}
}
if
(
!
isset
(
$def
[
'max'
]))
{
if
(
!
isset
(
$def
[
'max'
]))
{
continue
;
continue
;
}
}
$constraints
[]
=
'CHECK ('
.
$
field
.
' <= '
.
$def
[
'max'
]
.
')'
;
$constraints
[]
=
'CHECK ('
.
$
def
[
'name'
]
.
' <= '
.
$def
[
'max'
]
.
')'
;
}
}
}
}
...
...
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
View file @
75bf53d7
...
@@ -367,17 +367,16 @@ class OraclePlatform extends AbstractPlatform
...
@@ -367,17 +367,16 @@ class OraclePlatform extends AbstractPlatform
$options
[
'indexes'
]
=
[];
$options
[
'indexes'
]
=
[];
$sql
=
parent
::
_getCreateTableSQL
(
$tableName
,
$columns
,
$options
);
$sql
=
parent
::
_getCreateTableSQL
(
$tableName
,
$columns
,
$options
);
foreach
(
$columns
as
$
name
=>
$
column
)
{
foreach
(
$columns
as
$column
)
{
if
(
isset
(
$column
[
'sequence'
]))
{
if
(
isset
(
$column
[
'sequence'
]))
{
$sql
[]
=
$this
->
getCreateSequenceSQL
(
$column
[
'sequence'
]);
$sql
[]
=
$this
->
getCreateSequenceSQL
(
$column
[
'sequence'
]);
}
}
if
(
!
isset
(
$column
[
'autoincrement'
])
||
!
$column
[
'autoincrement'
]
&&
if
(
empty
(
$column
[
'autoincrement'
]))
{
(
!
isset
(
$column
[
'autoinc'
])
||
!
$column
[
'autoinc'
]))
{
continue
;
continue
;
}
}
$sql
=
array_merge
(
$sql
,
$this
->
getCreateAutoincrementSql
(
$
name
,
$tableName
));
$sql
=
array_merge
(
$sql
,
$this
->
getCreateAutoincrementSql
(
$
column
[
'name'
]
,
$tableName
));
}
}
if
(
isset
(
$indexes
)
&&
!
empty
(
$indexes
))
{
if
(
isset
(
$indexes
)
&&
!
empty
(
$indexes
))
{
...
...
lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
View file @
75bf53d7
...
@@ -368,8 +368,10 @@ class SqlitePlatform extends AbstractPlatform
...
@@ -368,8 +368,10 @@ class SqlitePlatform extends AbstractPlatform
$keyColumns
=
array_unique
(
array_values
(
$options
[
'primary'
]));
$keyColumns
=
array_unique
(
array_values
(
$options
[
'primary'
]));
foreach
(
$keyColumns
as
$keyColumn
)
{
foreach
(
$keyColumns
as
$keyColumn
)
{
if
(
!
empty
(
$columns
[
$keyColumn
][
'autoincrement'
]))
{
foreach
(
$columns
as
$column
)
{
return
''
;
if
(
$column
[
'name'
]
===
$keyColumn
&&
!
empty
(
$column
[
'autoincrement'
]))
{
return
''
;
}
}
}
}
}
...
...
tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php
View file @
75bf53d7
...
@@ -44,8 +44,15 @@ class TemporaryTableTest extends DbalFunctionalTestCase
...
@@ -44,8 +44,15 @@ class TemporaryTableTest extends DbalFunctionalTestCase
}
}
$platform
=
$this
->
connection
->
getDatabasePlatform
();
$platform
=
$this
->
connection
->
getDatabasePlatform
();
$columnDefinitions
=
[
'id'
=>
[
'type'
=>
Type
::
getType
(
'integer'
),
'notnull'
=>
true
]];
$columnDefinitions
=
[
$tempTable
=
$platform
->
getTemporaryTableName
(
'my_temporary'
);
[
'name'
=>
'id'
,
'type'
=>
Type
::
getType
(
'integer'
),
'notnull'
=>
true
,
],
];
$tempTable
=
$platform
->
getTemporaryTableName
(
'my_temporary'
);
$createTempTableSQL
=
$platform
->
getCreateTemporaryTableSnippetSQL
()
.
' '
.
$tempTable
.
' ('
$createTempTableSQL
=
$platform
->
getCreateTemporaryTableSnippetSQL
()
.
' '
.
$tempTable
.
' ('
.
$platform
->
getColumnDeclarationListSQL
(
$columnDefinitions
)
.
')'
;
.
$platform
->
getColumnDeclarationListSQL
(
$columnDefinitions
)
.
')'
;
...
@@ -79,8 +86,15 @@ class TemporaryTableTest extends DbalFunctionalTestCase
...
@@ -79,8 +86,15 @@ class TemporaryTableTest extends DbalFunctionalTestCase
}
}
$platform
=
$this
->
connection
->
getDatabasePlatform
();
$platform
=
$this
->
connection
->
getDatabasePlatform
();
$columnDefinitions
=
[
'id'
=>
[
'type'
=>
Type
::
getType
(
'integer'
),
'notnull'
=>
true
]];
$columnDefinitions
=
[
$tempTable
=
$platform
->
getTemporaryTableName
(
'my_temporary'
);
[
'name'
=>
'id'
,
'type'
=>
Type
::
getType
(
'integer'
),
'notnull'
=>
true
,
],
];
$tempTable
=
$platform
->
getTemporaryTableName
(
'my_temporary'
);
$createTempTableSQL
=
$platform
->
getCreateTemporaryTableSnippetSQL
()
.
' '
.
$tempTable
.
' ('
$createTempTableSQL
=
$platform
->
getCreateTemporaryTableSnippetSQL
()
.
' '
.
$tempTable
.
' ('
.
$platform
->
getColumnDeclarationListSQL
(
$columnDefinitions
)
.
')'
;
.
$platform
->
getColumnDeclarationListSQL
(
$columnDefinitions
)
.
')'
;
...
...
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