Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 6ca925b0
authored
Feb 22, 2017
by
Stefano Dalpiaz
Committed by
Sushant
Feb 22, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add quotes around column names for unique constraints in sqlite (fixes #4407) (#7270)
1 parent
99d406ea
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
1 deletions
changelog.md
lib/dialects/sqlite/query-generator.js
test/unit/dialects/sqlite/query-generator.test.js
changelog.md
View file @
6ca925b
# Future
-
[
FIXED
]
Add quotes around column names for unique constraints in sqlite
[
#4407
](
https://github.com/sequelize/sequelize/issues/4407
)
# 3.30.2
# 3.30.2
-
[
FIXED
]
`previous`
method gave wrong value back
[
#7189
](
https://github.com/sequelize/sequelize/pull/7189
)
-
[
FIXED
]
`previous`
method gave wrong value back
[
#7189
](
https://github.com/sequelize/sequelize/pull/7189
)
-
[
FIXED
]
Fixes setAssociation with scope
[
#7223
](
https://github.com/sequelize/sequelize/pull/7223
)
-
[
FIXED
]
Fixes setAssociation with scope
[
#7223
](
https://github.com/sequelize/sequelize/pull/7223
)
...
...
lib/dialects/sqlite/query-generator.js
View file @
6ca925b
...
@@ -69,9 +69,10 @@ var QueryGenerator = {
...
@@ -69,9 +69,10 @@ var QueryGenerator = {
,
pkString
=
primaryKeys
.
map
(
function
(
pk
)
{
return
this
.
quoteIdentifier
(
pk
);
}.
bind
(
this
)).
join
(
', '
);
,
pkString
=
primaryKeys
.
map
(
function
(
pk
)
{
return
this
.
quoteIdentifier
(
pk
);
}.
bind
(
this
)).
join
(
', '
);
if
(
!!
options
.
uniqueKeys
)
{
if
(
!!
options
.
uniqueKeys
)
{
var
quoteIdentifier
=
this
.
quoteIdentifier
.
bind
(
this
);
Utils
.
_
.
each
(
options
.
uniqueKeys
,
function
(
columns
)
{
Utils
.
_
.
each
(
options
.
uniqueKeys
,
function
(
columns
)
{
if
(
!
columns
.
singleField
)
{
// If it's a single field its handled in column def, not as an index
if
(
!
columns
.
singleField
)
{
// If it's a single field its handled in column def, not as an index
values
.
attributes
+=
', UNIQUE ('
+
columns
.
fields
.
join
(
', '
)
+
')'
;
values
.
attributes
+=
', UNIQUE ('
+
columns
.
fields
.
map
(
function
(
field
)
{
return
quoteIdentifier
(
field
);
}).
join
(
', '
)
+
')'
;
}
}
});
});
}
}
...
...
test/unit/dialects/sqlite/query-generator.test.js
View file @
6ca925b
...
@@ -135,6 +135,10 @@ if (dialect === 'sqlite') {
...
@@ -135,6 +135,10 @@ if (dialect === 'sqlite') {
{
{
arguments
:
[
'myTable'
,
{
id
:
'INTEGER PRIMARY KEY AUTOINCREMENT'
,
name
:
'VARCHAR(255)'
}],
arguments
:
[
'myTable'
,
{
id
:
'INTEGER PRIMARY KEY AUTOINCREMENT'
,
name
:
'VARCHAR(255)'
}],
expectation
:
'CREATE TABLE IF NOT EXISTS `myTable` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` VARCHAR(255));'
expectation
:
'CREATE TABLE IF NOT EXISTS `myTable` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` VARCHAR(255));'
},
{
arguments
:
[
'myTable'
,
{
id
:
'INTEGER PRIMARY KEY AUTOINCREMENT'
,
name
:
'VARCHAR(255)'
,
surname
:
'VARCHAR(255)'
},
{
uniqueKeys
:
{
uniqueConstraint
:
{
fields
:
[
'name'
,
'surname'
]}}}],
expectation
:
'CREATE TABLE IF NOT EXISTS `myTable` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` VARCHAR(255), `surname` VARCHAR(255), UNIQUE (`name`, `surname`));'
}
}
],
],
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment