Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
PSDI Army
yii2
Commits
02c3c37a
Commit
02c3c37a
authored
Apr 05, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #2986.
parent
c4e1416e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
7 deletions
+7
-7
Generator.php
extensions/gii/generators/model/Generator.php
+6
-6
Schema.php
framework/db/mysql/Schema.php
+1
-1
No files found.
extensions/gii/generators/model/Generator.php
View file @
02c3c37a
...
...
@@ -255,8 +255,8 @@ class Generator extends \yii\gii\Generator
$db
=
$this
->
getDbConnection
();
$uniqueIndexes
=
$db
->
getSchema
()
->
findUniqueIndexes
(
$table
);
foreach
(
$uniqueIndexes
as
$uniqueColumns
)
{
// Avoid validating auto incrementa
ble
columns
if
(
!
$this
->
is
UniqueColumnAutoIncrementable
(
$table
,
$uniqueColumns
))
{
// Avoid validating auto incrementa
l
columns
if
(
!
$this
->
is
ColumnAutoIncremental
(
$table
,
$uniqueColumns
))
{
$attributesCount
=
count
(
$uniqueColumns
);
if
(
$attributesCount
==
1
)
{
...
...
@@ -579,15 +579,15 @@ class Generator extends \yii\gii\Generator
}
/**
* Checks if any of the specified columns
of an unique index is auto incrementable
.
* Checks if any of the specified columns
is auto incremental
.
* @param \yii\db\TableSchema $table the table schema
* @param array $columns columns to check for autoIncrement property
* @return boolean whether any of the specified columns is auto incrementa
ble
.
* @return boolean whether any of the specified columns is auto incrementa
l
.
*/
protected
function
is
UniqueColumnAutoIncrementable
(
$table
,
$columns
)
protected
function
is
ColumnAutoIncremental
(
$table
,
$columns
)
{
foreach
(
$columns
as
$column
)
{
if
(
$table
->
columns
[
$column
]
->
autoIncrement
)
{
if
(
isset
(
$table
->
columns
[
$column
])
&&
$table
->
columns
[
$column
]
->
autoIncrement
)
{
return
true
;
}
}
...
...
framework/db/mysql/Schema.php
View file @
02c3c37a
...
...
@@ -267,7 +267,7 @@ class Schema extends \yii\db\Schema
$sql
=
$this
->
getCreateTableSql
(
$table
);
$uniqueIndexes
=
[];
$regexp
=
'/UNIQUE KEY\s+([^\(
^\s]+)\s*\(([^
\)]+)\)/mi'
;
$regexp
=
'/UNIQUE KEY\s+([^\(
\s]+)\s*\(([^\(
\)]+)\)/mi'
;
if
(
preg_match_all
(
$regexp
,
$sql
,
$matches
,
PREG_SET_ORDER
))
{
foreach
(
$matches
as
$match
)
{
$indexName
=
str_replace
(
'`'
,
''
,
$match
[
1
]);
...
...
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