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 d865b248
authored
May 10, 2020
by
Ivan Rubinson
Committed by
GitHub
May 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(sqlite): multiple primary keys results in syntax error (#12241)
1 parent
028f656a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
1 deletions
lib/dialects/sqlite/query-generator.js
test/unit/dialects/sqlite/query-generator.test.js
lib/dialects/sqlite/query-generator.js
View file @
d865b24
...
...
@@ -44,7 +44,11 @@ class SQLiteQueryGenerator extends MySqlQueryGenerator {
if
(
needsMultiplePrimaryKeys
)
{
primaryKeys
.
push
(
attr
);
dataTypeString
=
dataType
.
replace
(
'PRIMARY KEY'
,
'NOT NULL'
);
if
(
dataType
.
includes
(
'NOT NULL'
))
{
dataTypeString
=
dataType
.
replace
(
' PRIMARY KEY'
,
''
);
}
else
{
dataTypeString
=
dataType
.
replace
(
'PRIMARY KEY'
,
'NOT NULL'
);
}
}
}
attrArray
.
push
(
`
${
this
.
quoteIdentifier
(
attr
)}
${
dataTypeString
}
`
);
...
...
test/unit/dialects/sqlite/query-generator.test.js
View file @
d865b24
...
...
@@ -152,6 +152,9 @@ if (dialect === 'sqlite') {
{
arguments
:
[
'myTable'
,
{
id
:
'INTEGER PRIMARY KEY AUTOINCREMENT'
,
name
:
'VARCHAR(255)'
,
surname
:
'VARCHAR(255)'
},
{
uniqueKeys
:
{
uniqueConstraint
:
{
fields
:
[
'name'
,
'surname'
],
customIndex
:
true
}
}
}],
expectation
:
'CREATE TABLE IF NOT EXISTS `myTable` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` VARCHAR(255), `surname` VARCHAR(255), UNIQUE (`name`, `surname`));'
},
{
arguments
:
[
'myTable'
,
{
foo1
:
'INTEGER PRIMARY KEY NOT NULL'
,
foo2
:
'INTEGER PRIMARY KEY NOT NULL'
}],
expectation
:
'CREATE TABLE IF NOT EXISTS `myTable` (`foo1` INTEGER NOT NULL, `foo2` INTEGER NOT NULL, PRIMARY KEY (`foo1`, `foo2`));'
}
],
...
...
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