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 74d2b5f1
authored
Jan 05, 2018
by
Michael McCabe
Committed by
Sushant
Jan 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(mysql/datatypes): no default null value for some data types (#8839)
1 parent
3397b237
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
4 deletions
lib/dialects/mysql/query-generator.js
test/unit/dialects/mysql/query-generator.test.js
lib/dialects/mysql/query-generator.js
View file @
74d2b5f
...
@@ -310,7 +310,8 @@ const QueryGenerator = {
...
@@ -310,7 +310,8 @@ const QueryGenerator = {
};
};
}
}
let
template
=
attribute
.
type
.
toString
({
escape
:
this
.
escape
.
bind
(
this
)
});
const
attributeString
=
attribute
.
type
.
toString
({
escape
:
this
.
escape
.
bind
(
this
)
});
let
template
=
attributeString
;
if
(
attribute
.
allowNull
===
false
)
{
if
(
attribute
.
allowNull
===
false
)
{
template
+=
' NOT NULL'
;
template
+=
' NOT NULL'
;
...
@@ -320,8 +321,8 @@ const QueryGenerator = {
...
@@ -320,8 +321,8 @@ const QueryGenerator = {
template
+=
' auto_increment'
;
template
+=
' auto_increment'
;
}
}
// B
lobs/texts cannot have a defaultV
alue
// B
LOB/TEXT/GEOMETRY/JSON cannot have a default v
alue
if
(
attribute
.
type
!==
'TEXT'
&&
attribute
.
type
.
_binary
!==
true
&&
Utils
.
defaultValueSchemable
(
attribute
.
defaultValue
))
{
if
(
!
_
.
includes
([
'BLOB'
,
'TEXT'
,
'GEOMETRY'
,
'JSON'
],
attributeString
)
&&
attribute
.
type
.
_binary
!==
true
&&
Utils
.
defaultValueSchemable
(
attribute
.
defaultValue
))
{
template
+=
' DEFAULT '
+
this
.
escape
(
attribute
.
defaultValue
);
template
+=
' DEFAULT '
+
this
.
escape
(
attribute
.
defaultValue
);
}
}
...
...
test/unit/dialects/mysql/query-generator.test.js
View file @
74d2b5f
...
@@ -75,7 +75,27 @@ if (dialect === 'mysql') {
...
@@ -75,7 +75,27 @@ if (dialect === 'mysql') {
arguments
:
[{
id
:
{
type
:
'INTEGER'
,
after
:
'Bar'
}}],
arguments
:
[{
id
:
{
type
:
'INTEGER'
,
after
:
'Bar'
}}],
expectation
:
{
id
:
'INTEGER AFTER `Bar`'
}
expectation
:
{
id
:
'INTEGER AFTER `Bar`'
}
},
},
// No Default Values allowed for certain types
{
title
:
'No Default value for MySQL BLOB allowed'
,
arguments
:
[{
id
:
{
type
:
'BLOB'
,
defaultValue
:
[]}}],
expectation
:
{
id
:
'BLOB'
}
},
{
title
:
'No Default value for MySQL TEXT allowed'
,
arguments
:
[{
id
:
{
type
:
'TEXT'
,
defaultValue
:
[]}}],
expectation
:
{
id
:
'TEXT'
}
},
{
title
:
'No Default value for MySQL GEOMETRY allowed'
,
arguments
:
[{
id
:
{
type
:
'GEOMETRY'
,
defaultValue
:
[]}}],
expectation
:
{
id
:
'GEOMETRY'
}
},
{
title
:
'No Default value for MySQL JSON allowed'
,
arguments
:
[{
id
:
{
type
:
'JSON'
,
defaultValue
:
[]}}],
expectation
:
{
id
:
'JSON'
}
},
// New references style
// New references style
{
{
arguments
:
[{
id
:
{
type
:
'INTEGER'
,
references
:
{
model
:
'Bar'
}}}],
arguments
:
[{
id
:
{
type
:
'INTEGER'
,
references
:
{
model
:
'Bar'
}}}],
...
...
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