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
81c9d601
Unverified
Commit
81c9d601
authored
May 30, 2019
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Getting rid of the column name index
parent
72a5e9ff
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 @
81c9d601
# 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
-
Column precision no longer defaults to 10. The default value is NULL.
...
...
lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php
View file @
81c9d601
...
...
@@ -9,14 +9,15 @@ use Doctrine\DBAL\Schema\Table;
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
{
/** @var Table */
private
$table
;
/** @var array<
string
, array<string, mixed>> */
/** @var array<
int
, array<string, mixed>> */
private
$columns
;
/** @var array<string, mixed> */
...
...
@@ -29,8 +30,8 @@ class SchemaCreateTableEventArgs extends SchemaEventArgs
private
$sql
=
[];
/**
* @param array<
string
, array<string, mixed>> $columns
* @param array<string, mixed>
$options
* @param array<
int
, array<string, mixed>> $columns
* @param array<string, mixed> $options
*/
public
function
__construct
(
Table
$table
,
array
$columns
,
array
$options
,
AbstractPlatform
$platform
)
{
...
...
@@ -46,7 +47,7 @@ class SchemaCreateTableEventArgs extends SchemaEventArgs
}
/**
* @return array<
string
, array<string, mixed>>
* @return array<
int
, array<string, mixed>>
*/
public
function
getColumns
()
:
array
{
...
...
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
81c9d601
...
...
@@ -1345,10 +1345,7 @@ abstract class AbstractPlatform
$columnData
[
'primary'
]
=
true
;
}
$columnName
=
$columnData
[
'name'
];
assert
(
is_string
(
$columnName
));
$columns
[
$columnName
]
=
$columnData
;
$columns
[]
=
$columnData
;
}
if
(
$this
->
_eventManager
!==
null
&&
$this
->
_eventManager
->
hasListeners
(
Events
::
onSchemaCreateTable
))
{
...
...
@@ -1875,9 +1872,9 @@ abstract class AbstractPlatform
/**
* Gets declaration of a number of fields in bulk.
*
* @param mixed[][] $fields A multidimensional a
ssociative a
rray.
* The first dimension determines the
field name, while the second
* dimension is keyed with the name of the properties
* @param mixed[][] $fields A multidimensional array.
* The first dimension determines the
ordinal position of the field,
*
while the second
dimension is keyed with the name of the properties
* of the field being declared as array indexes. Currently, the types
* of supported field properties are as follows:
*
...
...
@@ -1903,8 +1900,8 @@ abstract class AbstractPlatform
{
$queryFields
=
[];
foreach
(
$fields
as
$field
Name
=>
$field
)
{
$queryFields
[]
=
$this
->
getColumnDeclarationSQL
(
$field
Name
,
$field
);
foreach
(
$fields
as
$field
)
{
$queryFields
[]
=
$this
->
getColumnDeclarationSQL
(
$field
[
'name'
]
,
$field
);
}
return
implode
(
', '
,
$queryFields
);
...
...
@@ -2050,19 +2047,19 @@ abstract class AbstractPlatform
public
function
getCheckDeclarationSQL
(
array
$definition
)
:
string
{
$constraints
=
[];
foreach
(
$definition
as
$
field
=>
$
def
)
{
foreach
(
$definition
as
$def
)
{
if
(
is_string
(
$def
))
{
$constraints
[]
=
'CHECK ('
.
$def
.
')'
;
}
else
{
if
(
isset
(
$def
[
'min'
]))
{
$constraints
[]
=
'CHECK ('
.
$
field
.
' >= '
.
$def
[
'min'
]
.
')'
;
$constraints
[]
=
'CHECK ('
.
$
def
[
'name'
]
.
' >= '
.
$def
[
'min'
]
.
')'
;
}
if
(
!
isset
(
$def
[
'max'
]))
{
continue
;
}
$constraints
[]
=
'CHECK ('
.
$
field
.
' <= '
.
$def
[
'max'
]
.
')'
;
$constraints
[]
=
'CHECK ('
.
$
def
[
'name'
]
.
' <= '
.
$def
[
'max'
]
.
')'
;
}
}
...
...
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
View file @
81c9d601
...
...
@@ -367,17 +367,16 @@ class OraclePlatform extends AbstractPlatform
$options
[
'indexes'
]
=
[];
$sql
=
parent
::
_getCreateTableSQL
(
$tableName
,
$columns
,
$options
);
foreach
(
$columns
as
$
name
=>
$
column
)
{
foreach
(
$columns
as
$column
)
{
if
(
isset
(
$column
[
'sequence'
]))
{
$sql
[]
=
$this
->
getCreateSequenceSQL
(
$column
[
'sequence'
]);
}
if
(
!
isset
(
$column
[
'autoincrement'
])
||
!
$column
[
'autoincrement'
]
&&
(
!
isset
(
$column
[
'autoinc'
])
||
!
$column
[
'autoinc'
]))
{
if
(
empty
(
$column
[
'autoincrement'
]))
{
continue
;
}
$sql
=
array_merge
(
$sql
,
$this
->
getCreateAutoincrementSql
(
$
name
,
$tableName
));
$sql
=
array_merge
(
$sql
,
$this
->
getCreateAutoincrementSql
(
$
column
[
'name'
]
,
$tableName
));
}
if
(
isset
(
$indexes
)
&&
!
empty
(
$indexes
))
{
...
...
lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
View file @
81c9d601
...
...
@@ -368,8 +368,10 @@ class SqlitePlatform extends AbstractPlatform
$keyColumns
=
array_unique
(
array_values
(
$options
[
'primary'
]));
foreach
(
$keyColumns
as
$keyColumn
)
{
if
(
!
empty
(
$columns
[
$keyColumn
][
'autoincrement'
]))
{
return
''
;
foreach
(
$columns
as
$column
)
{
if
(
$column
[
'name'
]
===
$keyColumn
&&
!
empty
(
$column
[
'autoincrement'
]))
{
return
''
;
}
}
}
...
...
tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php
View file @
81c9d601
...
...
@@ -44,8 +44,15 @@ class TemporaryTableTest extends DbalFunctionalTestCase
}
$platform
=
$this
->
connection
->
getDatabasePlatform
();
$columnDefinitions
=
[
'id'
=>
[
'type'
=>
Type
::
getType
(
'integer'
),
'notnull'
=>
true
]];
$tempTable
=
$platform
->
getTemporaryTableName
(
'my_temporary'
);
$columnDefinitions
=
[
[
'name'
=>
'id'
,
'type'
=>
Type
::
getType
(
'integer'
),
'notnull'
=>
true
,
],
];
$tempTable
=
$platform
->
getTemporaryTableName
(
'my_temporary'
);
$createTempTableSQL
=
$platform
->
getCreateTemporaryTableSnippetSQL
()
.
' '
.
$tempTable
.
' ('
.
$platform
->
getColumnDeclarationListSQL
(
$columnDefinitions
)
.
')'
;
...
...
@@ -79,8 +86,15 @@ class TemporaryTableTest extends DbalFunctionalTestCase
}
$platform
=
$this
->
connection
->
getDatabasePlatform
();
$columnDefinitions
=
[
'id'
=>
[
'type'
=>
Type
::
getType
(
'integer'
),
'notnull'
=>
true
]];
$tempTable
=
$platform
->
getTemporaryTableName
(
'my_temporary'
);
$columnDefinitions
=
[
[
'name'
=>
'id'
,
'type'
=>
Type
::
getType
(
'integer'
),
'notnull'
=>
true
,
],
];
$tempTable
=
$platform
->
getTemporaryTableName
(
'my_temporary'
);
$createTempTableSQL
=
$platform
->
getCreateTemporaryTableSnippetSQL
()
.
' '
.
$tempTable
.
' ('
.
$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