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 893a5d78
authored
Apr 06, 2015
by
Mick Hansen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3445 from Americas/master
Fix ENUM Type Name
2 parents
41a52af1
69e27432
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
lib/query-interface.js
test/integration/query-interface.test.js
lib/query-interface.js
View file @
893a5d7
...
...
@@ -83,7 +83,7 @@ module.exports = (function() {
if
(
typeof
attribute
.
defaultValue
===
"function"
&&
(
attribute
.
defaultValue
===
DataTypes
.
NOW
||
attribute
.
defaultValue
===
DataTypes
.
UUIDV4
||
attribute
.
defaultValue
===
DataTypes
.
UUIDV4
attribute
.
defaultValue
===
DataTypes
.
UUIDV4
))
{
attribute
.
defaultValue
=
new
attribute
.
defaultValue
();
}
...
...
@@ -114,7 +114,7 @@ module.exports = (function() {
for
(
i
=
0
;
i
<
keyLen
;
i
++
)
{
if
(
attributes
[
keys
[
i
]].
type
instanceof
DataTypes
.
ENUM
)
{
sql
=
self
.
QueryGenerator
.
pgListEnums
(
getTableName
,
keys
[
i
],
options
);
sql
=
self
.
QueryGenerator
.
pgListEnums
(
getTableName
,
attributes
[
keys
[
i
]].
field
||
keys
[
i
],
options
);
promises
.
push
(
self
.
sequelize
.
query
(
sql
,
null
,
{
plain
:
true
,
raw
:
true
,
type
:
QueryTypes
.
SELECT
,
logging
:
options
.
logging
}));
}
}
...
...
@@ -131,7 +131,7 @@ module.exports = (function() {
if
(
attributes
[
keys
[
i
]].
type
instanceof
DataTypes
.
ENUM
)
{
// If the enum type doesn't exist then create it
if
(
!
results
[
enumIdx
])
{
sql
=
self
.
QueryGenerator
.
pgEnum
(
getTableName
,
keys
[
i
],
attributes
[
keys
[
i
]],
options
);
sql
=
self
.
QueryGenerator
.
pgEnum
(
getTableName
,
attributes
[
keys
[
i
]].
field
||
keys
[
i
],
attributes
[
keys
[
i
]],
options
);
promises
.
push
(
self
.
sequelize
.
query
(
sql
,
null
,
{
raw
:
true
,
logging
:
options
.
logging
}));
}
else
if
(
!!
results
[
enumIdx
]
&&
!!
daoTable
)
{
var
enumVals
=
self
.
QueryGenerator
.
fromArray
(
results
[
enumIdx
].
enum_value
)
...
...
@@ -632,7 +632,7 @@ module.exports = (function() {
return
Promise
.
reduce
(
cascades
,
function
(
memo
,
cascade
)
{
return
dao
[
cascade
]().
then
(
function
(
instances
)
{
if
(
!
Array
.
isArray
(
instances
))
instances
=
[
instances
];
return
Promise
.
reduce
(
instances
,
function
(
memo
,
instance
)
{
return
instance
.
destroy
();
},
[]);
...
...
test/integration/query-interface.test.js
View file @
893a5d7
...
...
@@ -165,6 +165,17 @@ describe(Support.getTestDialectTeaser('QueryInterface'), function() {
});
});
it
(
'should work with enums (3)'
,
function
()
{
return
this
.
queryInterface
.
createTable
(
'SomeTable'
,
{
someEnum
:
{
type
:
DataTypes
.
ENUM
,
values
:
[
'value1'
,
'value2'
,
'value3'
],
field
:
"otherName"
}
});
});
it
(
'should work with schemas'
,
function
()
{
var
self
=
this
;
return
self
.
sequelize
.
dropAllSchemas
().
then
(
function
()
{
...
...
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