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 a14773ab
authored
Mar 08, 2014
by
Jan Aagaard Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix handling of INTEGER PRIMARY KEY for sqlite (remove length, unsigned etc.)
1 parent
fdba0dd4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
7 deletions
lib/dialects/sqlite/query-generator.js
test/sqlite/query-generator.test.js
lib/dialects/sqlite/query-generator.js
View file @
a14773a
...
@@ -93,12 +93,17 @@ module.exports = (function() {
...
@@ -93,12 +93,17 @@ module.exports = (function() {
modifierLastIndex
=
-
1
modifierLastIndex
=
-
1
}
}
if
(
Utils
.
_
.
includes
(
dataType
,
'PRIMARY KEY'
)
&&
needsMultiplePrimaryKeys
)
{
if
(
Utils
.
_
.
includes
(
dataType
,
'PRIMARY KEY'
))
{
primaryKeys
.
push
(
attr
)
if
(
Utils
.
_
.
includes
(
dataType
,
'INTEGER'
))
{
attrStr
.
push
(
this
.
quoteIdentifier
(
attr
)
+
" "
+
dataType
.
replace
(
/PRIMARY KEY/
,
'NOT NULL'
))
dataType
=
'INTEGER PRIMARY KEY'
// Only INTEGER is allowed for primary key, see https://github.com/sequelize/sequelize/issues/969 (no lenght, unsigned etc)
}
else
{
}
attrStr
.
push
(
this
.
quoteIdentifier
(
attr
)
+
" "
+
dataType
)
if
(
needsMultiplePrimaryKeys
)
{
primaryKeys
.
push
(
attr
)
dataType
=
dataType
.
replace
(
/PRIMARY KEY/
,
'NOT NULL'
)
}
}
}
attrStr
.
push
(
this
.
quoteIdentifier
(
attr
)
+
" "
+
dataType
)
}
}
}
}
...
...
test/sqlite/query-generator.test.js
View file @
a14773a
...
@@ -91,8 +91,8 @@ if (dialect === 'sqlite') {
...
@@ -91,8 +91,8 @@ if (dialect === 'sqlite') {
expectation
:
"CREATE TABLE IF NOT EXISTS `myTable` (`title` VARCHAR(255), `name` VARCHAR(255));"
expectation
:
"CREATE TABLE IF NOT EXISTS `myTable` (`title` VARCHAR(255), `name` VARCHAR(255));"
},
},
{
{
arguments
:
[
'myTable'
,
{
title
:
'VARCHAR(255) BINARY'
,
number
:
'INTEGER(5) UNSIGNED PRIMARY KEY '
}],
arguments
:
[
'myTable'
,
{
title
:
'VARCHAR(255) BINARY'
,
number
:
'INTEGER(5) UNSIGNED PRIMARY KEY '
}],
// length and unsigned are not allowed on primary key
expectation
:
"CREATE TABLE IF NOT EXISTS `myTable` (`title` VARCHAR BINARY(255), `number` INTEGER
UNSIGNED(5)
PRIMARY KEY);"
expectation
:
"CREATE TABLE IF NOT EXISTS `myTable` (`title` VARCHAR BINARY(255), `number` INTEGER PRIMARY KEY);"
},
},
{
{
arguments
:
[
'myTable'
,
{
title
:
'ENUM("A", "B", "C")'
,
name
:
'VARCHAR(255)'
}],
arguments
:
[
'myTable'
,
{
title
:
'ENUM("A", "B", "C")'
,
name
:
'VARCHAR(255)'
}],
...
...
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