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
6c6cb3cd
Commit
6c6cb3cd
authored
Sep 13, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #853: Added composite FK support for SQLite.
parent
02fd82c4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
6 deletions
+7
-6
Schema.php
framework/yii/db/sqlite/Schema.php
+7
-1
SqliteSchemaTest.php
tests/unit/framework/db/sqlite/SqliteSchemaTest.php
+0
-5
No files found.
framework/yii/db/sqlite/Schema.php
View file @
6c6cb3cd
...
@@ -126,7 +126,13 @@ class Schema extends \yii\db\Schema
...
@@ -126,7 +126,13 @@ class Schema extends \yii\db\Schema
$sql
=
"PRAGMA foreign_key_list("
.
$this
->
quoteSimpleTableName
(
$table
->
name
)
.
')'
;
$sql
=
"PRAGMA foreign_key_list("
.
$this
->
quoteSimpleTableName
(
$table
->
name
)
.
')'
;
$keys
=
$this
->
db
->
createCommand
(
$sql
)
->
queryAll
();
$keys
=
$this
->
db
->
createCommand
(
$sql
)
->
queryAll
();
foreach
(
$keys
as
$key
)
{
foreach
(
$keys
as
$key
)
{
$table
->
foreignKeys
[]
=
array
(
$key
[
'table'
],
$key
[
'from'
]
=>
$key
[
'to'
]);
$id
=
(
int
)
$key
[
'id'
];
if
(
!
isset
(
$table
->
foreignKeys
[
$id
]))
{
$table
->
foreignKeys
[
$id
]
=
array
(
$key
[
'table'
],
$key
[
'from'
]
=>
$key
[
'to'
]);
}
else
{
// composite FK
$table
->
foreignKeys
[
$id
][
$key
[
'from'
]]
=
$key
[
'to'
];
}
}
}
}
}
...
...
tests/unit/framework/db/sqlite/SqliteSchemaTest.php
View file @
6c6cb3cd
...
@@ -6,9 +6,4 @@ use yiiunit\framework\db\SchemaTest;
...
@@ -6,9 +6,4 @@ use yiiunit\framework\db\SchemaTest;
class
SqliteSchemaTest
extends
SchemaTest
class
SqliteSchemaTest
extends
SchemaTest
{
{
protected
$driverName
=
'sqlite'
;
protected
$driverName
=
'sqlite'
;
public
function
testCompositeFk
()
{
$this
->
markTestSkipped
(
'sqlite does not allow getting enough information about composite FK.'
);
}
}
}
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