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
4ddc496d
Unverified
Commit
4ddc496d
authored
Oct 11, 2017
by
belgattitude
Committed by
Luís Cobucci
Nov 19, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes from @lcobucci review
parent
d4c2be87
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
25 deletions
+29
-25
AbstractMySQLDriver.php
lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php
+15
-13
MySqlSchemaManager.php
lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php
+14
-12
No files found.
lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php
View file @
4ddc496d
...
...
@@ -39,6 +39,10 @@ use Doctrine\DBAL\VersionAwarePlatformDriver;
*/
abstract
class
AbstractMySQLDriver
implements
Driver
,
ExceptionConverterDriver
,
VersionAwarePlatformDriver
{
private
const
MYSQL_MARIADB_VERSION_REGEXP
=
'/^(mariadb-)?(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)/'
;
private
const
MYSQL_ORACLE_VERSION_REGEXP
=
'/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/'
;
/**
* {@inheritdoc}
*
...
...
@@ -130,18 +134,16 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver,
* @return AbstractPlatform|MariaDb102Platform|MySQL57Platform|MySqlPlatform
* @throws DBALException
*/
public
function
createDatabasePlatformForVersion
(
$version
)
:
AbstractPlatform
public
function
createDatabasePlatformForVersion
(
$version
)
{
if
(
false
!==
stripos
(
$version
,
'mariadb'
))
{
$versionNumber
=
$this
->
getMariaDbMysqlVersionNumber
(
$version
);
if
(
version_compare
(
$versionNumber
,
'10.2.7'
,
'>='
))
{
return
new
MariaDb102Platform
();
}
}
else
{
$versionNumber
=
$this
->
getOracleMysqlVersionNumber
(
$version
);
if
(
version_compare
(
$versionNumber
,
'5.7.9'
,
'>='
))
{
return
new
MySQL57Platform
();
}
if
(
false
!==
stripos
(
$version
,
'mariadb'
)
&&
version_compare
(
$this
->
getMariaDbMysqlVersionNumber
(
$version
),
'10.2.7'
,
'>='
))
{
return
new
MariaDb102Platform
();
}
if
(
false
===
stripos
(
$version
,
'mariadb'
)
&&
version_compare
(
$this
->
getOracleMysqlVersionNumber
(
$version
),
'5.7.9'
,
'>='
))
{
return
new
MySQL57Platform
();
}
return
$this
->
getDatabasePlatform
();
...
...
@@ -156,7 +158,7 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver,
*/
private
function
getOracleMysqlVersionNumber
(
string
$versionString
)
:
string
{
if
(
!
preg_match
(
'/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/'
,
$versionString
,
$versionParts
))
{
if
(
!
preg_match
(
self
::
MYSQL_ORACLE_VERSION_REGEXP
,
$versionString
,
$versionParts
))
{
throw
DBALException
::
invalidPlatformVersionSpecified
(
$versionString
,
'<major_version>.<minor_version>.<patch_version>'
...
...
@@ -184,7 +186,7 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver,
{
$version
=
str_replace
(
'5.5.5-'
,
''
,
$versionString
);
if
(
!
preg_match
(
'/^(mariadb-)?(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)/'
,
strtolower
(
$version
),
$versionParts
))
{
if
(
!
preg_match
(
self
::
MYSQL_MARIADB_VERSION_REGEXP
,
strtolower
(
$version
),
$versionParts
))
{
throw
DBALException
::
invalidPlatformVersionSpecified
(
$version
,
'(mariadb-)?<major_version>.<minor_version>.<patch_version>'
...
...
lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php
View file @
4ddc496d
...
...
@@ -227,24 +227,26 @@ class MySqlSchemaManager extends AbstractSchemaManager
* @param null|string $columnDefault default value as stored in information_schema for MariaDB >= 10.2.7
*/
private
function
getMariaDb1027ColumnDefault
(
MariaDb102Platform
$platform
,
?
string
$columnDefault
)
:
?
string
{
if
(
$columnDefault
===
'NULL'
||
$columnDefault
===
null
)
{
$defaultValue
=
null
;
}
elseif
(
strpos
(
$columnDefault
,
"'"
)
===
0
)
{
$defaultValue
=
stripslashes
(
return
null
;
}
if
(
strpos
(
$columnDefault
,
"'"
)
===
0
)
{
return
stripslashes
(
str_replace
(
"''"
,
"'"
,
preg_replace
(
'/^\'(.*)\'$/'
,
'$1'
,
$columnDefault
)
)
);
}
elseif
(
$columnDefault
===
'current_timestamp()'
)
{
$defaultValue
=
$platform
->
getCurrentTimestampSQL
();
}
elseif
(
$columnDefault
===
'curdate()'
)
{
$defaultValue
=
$platform
->
getCurrentDateSQL
();
}
elseif
(
$columnDefault
===
'curtime()'
)
{
$defaultValue
=
$platform
->
getCurrentTimeSQL
();
}
else
{
$defaultValue
=
$columnDefault
;
}
return
$defaultValue
;
switch
(
$columnDefault
)
{
case
'current_timestamp()'
:
return
$platform
->
getCurrentTimestampSQL
();
case
'curdate()'
:
return
$platform
->
getCurrentDateSQL
();
case
'curtime()'
:
return
$platform
->
getCurrentTimeSQL
();
}
return
$columnDefault
;
}
/**
...
...
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