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 bde6d501
authored
Sep 11, 2017
by
Maurice Ronet Dominguez
Committed by
Sushant
Sep 11, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(queryGenerator): createTrigger fails with correct event specs (#8282)
1 parent
0ca7299f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
3 deletions
lib/dialects/postgres/query-generator.js
test/unit/dialects/postgres/query-generator.test.js
lib/dialects/postgres/query-generator.js
View file @
bde6d50
...
...
@@ -713,11 +713,11 @@ const QueryGenerator = {
'truncate'
:
'TRUNCATE'
};
if
(
!
Utils
.
_
.
has
(
EVENT_MAP
,
fire
Key
))
{
if
(
!
Utils
.
_
.
has
(
EVENT_MAP
,
fire
Value
))
{
throw
new
Error
(
'parseTriggerEventSpec: undefined trigger event '
+
fireKey
);
}
let
eventSpec
=
EVENT_MAP
[
fire
Key
];
let
eventSpec
=
EVENT_MAP
[
fire
Value
];
if
(
eventSpec
===
'UPDATE'
)
{
if
(
Utils
.
_
.
isArray
(
fireValue
)
&&
fireValue
.
length
>
0
)
{
eventSpec
+=
' OF '
+
fireValue
.
join
(
', '
);
...
...
test/unit/dialects/postgres/query-generator.test.js
View file @
bde6d50
...
...
@@ -422,7 +422,7 @@ if (dialect.match(/^postgres/)) {
},
{
title
:
'string in array should escape \' as \'\''
,
arguments
:
[
'myTable'
,
{
where
:
{
aliases
:
{
$contains
:
[
'Queen\'s'
]}
}}],
expectation
:
"SELECT * FROM \"myTable\" WHERE \"myTable\".\"aliases\" @> ARRAY['Queen''s'];"
,
expectation
:
"SELECT * FROM \"myTable\" WHERE \"myTable\".\"aliases\" @> ARRAY['Queen''s'];"
},
// Variants when quoteIdentifiers is false
...
...
@@ -904,6 +904,25 @@ if (dialect.match(/^postgres/)) {
expectation
:
'ROLLBACK TO SAVEPOINT \"transaction-uid\";'
,
context
:
{
options
:
{
quoteIdentifiers
:
true
}}
}
],
createTrigger
:
[
{
arguments
:
[
'myTable'
,
'myTrigger'
,
'after'
,
[
'insert'
],
'myFunction'
,
[],
[]],
expectation
:
'CREATE TRIGGER myTrigger\n\tAFTER INSERT\n\tON myTable\n\t\n\tEXECUTE PROCEDURE myFunction();'
},
{
arguments
:
[
'myTable'
,
'myTrigger'
,
'before'
,
[
'insert'
,
'update'
],
'myFunction'
,
[{
name
:
'bar'
,
type
:
'INTEGER'
}],
[]],
expectation
:
'CREATE TRIGGER myTrigger\n\tBEFORE INSERT OR UPDATE\n\tON myTable\n\t\n\tEXECUTE PROCEDURE myFunction(bar INTEGER);'
},
{
arguments
:
[
'myTable'
,
'myTrigger'
,
'instead_of'
,
[
'insert'
,
'update'
],
'myFunction'
,
[],
[
'FOR EACH ROW'
]],
expectation
:
'CREATE TRIGGER myTrigger\n\tINSTEAD OF INSERT OR UPDATE\n\tON myTable\n\t\n\tFOR EACH ROW\n\tEXECUTE PROCEDURE myFunction();'
},
{
arguments
:
[
'myTable'
,
'myTrigger'
,
'after_constraint'
,
[
'insert'
,
'update'
],
'myFunction'
,
[{
name
:
'bar'
,
type
:
'INTEGER'
}],
[
'FOR EACH ROW'
]],
expectation
:
'CREATE CONSTRAINT TRIGGER myTrigger\n\tAFTER INSERT OR UPDATE\n\tON myTable\n\t\n\tFOR EACH ROW\n\tEXECUTE PROCEDURE myFunction(bar INTEGER);'
}
]
};
...
...
@@ -924,6 +943,7 @@ if (dialect.match(/^postgres/)) {
if
(
_
.
isFunction
(
test
.
arguments
[
1
]))
test
.
arguments
[
1
]
=
test
.
arguments
[
1
](
this
.
sequelize
);
if
(
_
.
isFunction
(
test
.
arguments
[
2
]))
test
.
arguments
[
2
]
=
test
.
arguments
[
2
](
this
.
sequelize
);
}
QueryGenerator
.
options
=
_
.
assign
(
context
.
options
,
{
timezone
:
'+00:00'
});
QueryGenerator
.
_dialect
=
this
.
sequelize
.
dialect
;
QueryGenerator
.
sequelize
=
this
.
sequelize
;
...
...
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