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 447a5f34
authored
Oct 05, 2013
by
Jan Aagaard Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move lenght to the end of data type for sqlite
1 parent
94ec0379
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
lib/dialects/sqlite/query-generator.js
test/sqlite/query-generator.test.js
lib/dialects/sqlite/query-generator.js
View file @
447a5f3
...
@@ -55,6 +55,7 @@ module.exports = (function() {
...
@@ -55,6 +55,7 @@ module.exports = (function() {
return
Utils
.
_
.
includes
(
definition
,
'PRIMARY KEY'
)
return
Utils
.
_
.
includes
(
definition
,
'PRIMARY KEY'
)
}).
length
>
1
)
}).
length
>
1
)
,
attrStr
=
[]
,
attrStr
=
[]
,
endParen
for
(
var
attr
in
attributes
)
{
for
(
var
attr
in
attributes
)
{
...
@@ -65,6 +66,17 @@ module.exports = (function() {
...
@@ -65,6 +66,17 @@ module.exports = (function() {
dataType
=
dataType
.
replace
(
/BIGINT/
,
'INTEGER'
)
dataType
=
dataType
.
replace
(
/BIGINT/
,
'INTEGER'
)
}
}
if
((
endParen
=
dataType
.
indexOf
(
')'
))
!==
-
1
&&
endParen
!==
(
dataType
.
length
-
1
))
{
// Move the length to the end of the string, as required by SQLite (needed for things like INTEGER(5) UNSIGNED -> INTEGER UNSIGNED(5))
var
match
=
dataType
.
match
(
/
\(\d
+
\)
/
)
if
(
match
)
{
match
=
match
[
0
]
dataType
=
dataType
.
replace
(
match
,
''
)
dataType
+=
match
}
}
if
(
Utils
.
_
.
includes
(
dataType
,
'PRIMARY KEY'
)
&&
needsMultiplePrimaryKeys
)
{
if
(
Utils
.
_
.
includes
(
dataType
,
'PRIMARY KEY'
)
&&
needsMultiplePrimaryKeys
)
{
primaryKeys
.
push
(
attr
)
primaryKeys
.
push
(
attr
)
attrStr
.
push
(
this
.
quoteIdentifier
(
attr
)
+
" "
+
dataType
.
replace
(
/PRIMARY KEY/
,
'NOT NULL'
))
attrStr
.
push
(
this
.
quoteIdentifier
(
attr
)
+
" "
+
dataType
.
replace
(
/PRIMARY KEY/
,
'NOT NULL'
))
...
...
test/sqlite/query-generator.test.js
View file @
447a5f3
...
@@ -91,6 +91,10 @@ if (dialect === 'sqlite') {
...
@@ -91,6 +91,10 @@ 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'
}],
expectation
:
"CREATE TABLE IF NOT EXISTS `myTable` (`title` VARCHAR BINARY(255), `number` INTEGER UNSIGNED(5));"
},
{
arguments
:
[
'myTable'
,
{
title
:
'ENUM("A", "B", "C")'
,
name
:
'VARCHAR(255)'
}],
arguments
:
[
'myTable'
,
{
title
:
'ENUM("A", "B", "C")'
,
name
:
'VARCHAR(255)'
}],
expectation
:
"CREATE TABLE IF NOT EXISTS `myTable` (`title` ENUM(\"A\", \"B\", \"C\"), `name` VARCHAR(255));"
expectation
:
"CREATE TABLE IF NOT EXISTS `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