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 0e699b63
authored
Jul 30, 2013
by
Daniel Durante
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MySQL will no longer try to create a text/blob column with a default value (there's no such thing).
1 parent
41a9810f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
2 deletions
lib/dialects/mysql/query-generator.js
test/mysql/dao-factory.test.js
test/mysql/query-generator.test.js
lib/dialects/mysql/query-generator.js
View file @
0e699b6
...
...
@@ -520,7 +520,8 @@ module.exports = (function() {
template
+=
" auto_increment"
}
if
((
dataType
.
defaultValue
!==
undefined
)
&&
(
dataType
.
defaultValue
!=
DataTypes
.
NOW
))
{
// Blobs/texts cannot have a defaultValue
if
(
dataType
.
type
!==
"TEXT"
&&
dataType
.
type
.
_binary
!==
true
&&
(
dataType
.
defaultValue
!==
undefined
)
&&
(
dataType
.
defaultValue
!=
DataTypes
.
NOW
))
{
template
+=
" DEFAULT "
+
this
.
escape
(
dataType
.
defaultValue
)
}
...
...
test/mysql/dao-factory.test.js
View file @
0e699b6
...
...
@@ -71,6 +71,18 @@ if (dialect.match(/^mysql/)) {
expect
(
User
.
attributes
).
to
.
deep
.
equal
({
id
:
"INTEGER NOT NULL auto_increment PRIMARY KEY"
,
deleted_at
:
"DATETIME"
,
updated_at
:
"DATETIME NOT NULL"
,
created_at
:
"DATETIME NOT NULL"
})
done
()
})
it
(
'omits text fields with defaultValues'
,
function
(
done
)
{
var
User
=
this
.
sequelize
.
define
(
'User'
+
config
.
rand
(),
{
name
:
{
type
:
DataTypes
.
TEXT
,
defaultValue
:
'helloworld'
}})
expect
(
User
.
attributes
.
name
).
to
.
equal
(
'TEXT'
)
done
()
})
it
(
'omits blobs fields with defaultValues'
,
function
(
done
)
{
var
User
=
this
.
sequelize
.
define
(
'User'
+
config
.
rand
(),
{
name
:
{
type
:
DataTypes
.
STRING
.
BINARY
,
defaultValue
:
'helloworld'
}})
expect
(
User
.
attributes
.
name
).
to
.
equal
(
'VARCHAR(255) BINARY'
)
done
()
})
})
describe
(
'primaryKeys'
,
function
()
{
...
...
test/mysql/query-generator.test.js
View file @
0e699b6
...
...
@@ -68,7 +68,7 @@ if (dialect.match(/^mysql/)) {
{
arguments
:
[{
id
:
{
type
:
'INTEGER'
,
allowNull
:
false
,
autoIncrement
:
true
,
defaultValue
:
1
,
references
:
'Bar'
,
onDelete
:
'CASCADE'
,
onUpdate
:
'RESTRICT'
}}],
expectation
:
{
id
:
'INTEGER NOT NULL auto_increment DEFAULT 1 REFERENCES `Bar` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT'
}
}
,
}
],
createTableQuery
:
[
...
...
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