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 635d11b7
authored
Nov 13, 2013
by
Jan Aagaard Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the logic for manipulating sqlite data types a bit more solid
1 parent
b85e232e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
3 deletions
lib/dialects/sqlite/query-generator.js
test/sqlite/query-generator.test.js
lib/dialects/sqlite/query-generator.js
View file @
635d11b
...
@@ -81,8 +81,15 @@ module.exports = (function() {
...
@@ -81,8 +81,15 @@ module.exports = (function() {
var
length
=
dataType
.
match
(
/
\(\s
*
\d
+
(\s
*,
\s
*
\d)?\s
*
\)
/
)
var
length
=
dataType
.
match
(
/
\(\s
*
\d
+
(\s
*,
\s
*
\d)?\s
*
\)
/
)
if
(
length
&&
length
.
index
<
modifierLastIndex
)
{
if
(
length
&&
length
.
index
<
modifierLastIndex
)
{
dataType
=
dataType
.
replace
(
length
[
0
],
''
)
dataType
=
dataType
.
replace
(
length
[
0
],
''
)
dataType
=
Utils
.
_
.
insert
(
dataType
,
modifierLastIndex
,
length
[
0
])
// Since the legnth was placed before the modifier, removing the legnth has changed the index
if
(
length
.
index
<
modifierLastIndex
)
{
modifierLastIndex
-=
length
[
0
].
length
}
dataType
=
Utils
.
_
.
insert
(
dataType
,
modifierLastIndex
,
length
[
0
]).
trim
()
}
}
modifierLastIndex
=
-
1
}
}
if
(
Utils
.
_
.
includes
(
dataType
,
'PRIMARY KEY'
)
&&
needsMultiplePrimaryKeys
)
{
if
(
Utils
.
_
.
includes
(
dataType
,
'PRIMARY KEY'
)
&&
needsMultiplePrimaryKeys
)
{
...
...
test/sqlite/query-generator.test.js
View file @
635d11b
...
@@ -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'
}],
arguments
:
[
'myTable'
,
{
title
:
'VARCHAR(255) BINARY'
,
number
:
'INTEGER(5) UNSIGNED
PRIMARY KEY
'
}],
expectation
:
"CREATE TABLE IF NOT EXISTS `myTable` (`title` VARCHAR BINARY(255), `number` INTEGER UNSIGNED(5));"
expectation
:
"CREATE TABLE IF NOT EXISTS `myTable` (`title` VARCHAR BINARY(255), `number` INTEGER UNSIGNED(5)
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