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 76a5f959
authored
Jun 15, 2015
by
ns3777k
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pass transaction dealing with pg enums
1 parent
4f0674b5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
lib/query-interface.js
lib/query-interface.js
View file @
76a5f95
...
...
@@ -119,7 +119,9 @@ QueryInterface.prototype.createTable = function(tableName, attributes, options)
for
(
i
=
0
;
i
<
keyLen
;
i
++
)
{
if
(
attributes
[
keys
[
i
]].
type
instanceof
DataTypes
.
ENUM
)
{
sql
=
self
.
QueryGenerator
.
pgListEnums
(
getTableName
,
attributes
[
keys
[
i
]].
field
||
keys
[
i
],
options
);
promises
.
push
(
self
.
sequelize
.
query
(
sql
,
{
plain
:
true
,
raw
:
true
,
type
:
QueryTypes
.
SELECT
,
logging
:
options
.
logging
}));
promises
.
push
(
self
.
sequelize
.
query
(
sql
,
{
plain
:
true
,
raw
:
true
,
type
:
QueryTypes
.
SELECT
,
logging
:
options
.
logging
,
transaction
:
options
.
transaction
}
));
}
}
...
...
@@ -135,7 +137,9 @@ QueryInterface.prototype.createTable = function(tableName, attributes, options)
// If the enum type doesn't exist then create it
if
(
!
results
[
enumIdx
])
{
sql
=
self
.
QueryGenerator
.
pgEnum
(
getTableName
,
attributes
[
keys
[
i
]].
field
||
keys
[
i
],
attributes
[
keys
[
i
]],
options
);
promises
.
push
(
self
.
sequelize
.
query
(
sql
,
{
raw
:
true
,
logging
:
options
.
logging
}));
promises
.
push
(
self
.
sequelize
.
query
(
sql
,
{
raw
:
true
,
logging
:
options
.
logging
,
transaction
:
options
.
transaction
}
));
}
else
if
(
!!
results
[
enumIdx
]
&&
!!
instanceTable
)
{
var
enumVals
=
self
.
QueryGenerator
.
fromArray
(
results
[
enumIdx
].
enum_value
)
,
vals
=
instanceTable
.
rawAttributes
[
keys
[
i
]].
values
;
...
...
@@ -218,7 +222,8 @@ QueryInterface.prototype.dropTable = function(tableName, options) {
for
(
i
=
0
;
i
<
keyLen
;
i
++
)
{
if
(
instanceTable
.
rawAttributes
[
keys
[
i
]].
type
instanceof
DataTypes
.
ENUM
)
{
promises
.
push
(
self
.
sequelize
.
query
(
self
.
QueryGenerator
.
pgEnumDrop
(
getTableName
,
keys
[
i
]),
{
logging
:
options
.
logging
,
raw
:
true
}));
sql
=
self
.
QueryGenerator
.
pgEnumDrop
(
getTableName
,
keys
[
i
]);
promises
.
push
(
self
.
sequelize
.
query
(
sql
,
{
logging
:
options
.
logging
,
raw
:
true
,
transaction
:
options
.
transaction
}));
}
}
}
...
...
@@ -292,7 +297,10 @@ QueryInterface.prototype.dropAllEnums = function(options) {
var
self
=
this
,
sql
=
this
.
QueryGenerator
.
pgListEnums
();
return
this
.
sequelize
.
query
(
sql
,
{
plain
:
false
,
raw
:
true
,
type
:
QueryTypes
.
SELECT
,
logging
:
options
.
logging
}).
map
(
function
(
result
)
{
return
this
.
sequelize
.
query
(
sql
,
{
plain
:
false
,
raw
:
true
,
type
:
QueryTypes
.
SELECT
,
logging
:
options
.
logging
,
transaction
:
options
.
transaction
}
).
map
(
function
(
result
)
{
return
self
.
sequelize
.
query
(
self
.
QueryGenerator
.
pgEnumDrop
(
null
,
null
,
self
.
QueryGenerator
.
pgEscapeAndQuote
(
result
.
enum_name
)),
{
logging
:
options
.
logging
,
raw
:
true
}
...
...
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