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 ff93d7c4
authored
Jul 27, 2019
by
javiertury
Committed by
Sushant
Jul 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(search_path): disable bindParam in updateQuery (#11236)
1 parent
47489ab1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
1 deletions
lib/dialects/abstract/query-generator.js
test/integration/model/searchPath.test.js
lib/dialects/abstract/query-generator.js
View file @
ff93d7c
...
...
@@ -338,13 +338,19 @@ class QueryGenerator {
const
values
=
[];
const
bind
=
[];
const
bindParam
=
options
.
bindParam
===
undefined
?
this
.
bindParam
(
bind
)
:
options
.
bindParam
;
const
modelAttributeMap
=
{};
let
outputFragment
=
''
;
let
tmpTable
=
''
;
// tmpTable declaration for trigger
let
selectFromTmp
=
''
;
// Select statement for trigger
let
suffix
=
''
;
if
(
_
.
get
(
this
,
[
'sequelize'
,
'options'
,
'dialectOptions'
,
'prependSearchPath'
])
||
options
.
searchPath
)
{
// Not currently supported with search path (requires output of multiple queries)
options
.
bindParam
=
false
;
}
const
bindParam
=
options
.
bindParam
===
undefined
?
this
.
bindParam
(
bind
)
:
options
.
bindParam
;
if
(
this
.
_dialect
.
supports
[
'LIMIT ON UPDATE'
]
&&
options
.
limit
)
{
if
(
this
.
dialect
!==
'mssql'
)
{
suffix
=
` LIMIT
${
this
.
escape
(
options
.
limit
)}
`
;
...
...
test/integration/model/searchPath.test.js
View file @
ff93d7c
...
...
@@ -467,6 +467,40 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});
});
});
describe
(
'Edit data via instance.update, retrieve updated instance via model.findAll'
,
()
=>
{
it
(
'should be able to update data via instance update in both schemas, and retrieve it via findAll with where'
,
function
()
{
const
Restaurant
=
this
.
Restaurant
;
return
Promise
.
all
([
Restaurant
.
create
({
foo
:
'one'
,
bar
:
'1'
},
{
searchPath
:
SEARCH_PATH_ONE
})
.
then
(
rnt
=>
rnt
.
update
({
bar
:
'x.1'
},
{
searchPath
:
SEARCH_PATH_ONE
})),
Restaurant
.
create
({
foo
:
'one'
,
bar
:
'2'
},
{
searchPath
:
SEARCH_PATH_ONE
})
.
then
(
rnt
=>
rnt
.
update
({
bar
:
'x.2'
},
{
searchPath
:
SEARCH_PATH_ONE
})),
Restaurant
.
create
({
foo
:
'two'
,
bar
:
'1'
},
{
searchPath
:
SEARCH_PATH_TWO
})
.
then
(
rnt
=>
rnt
.
update
({
bar
:
'x.1'
},
{
searchPath
:
SEARCH_PATH_TWO
})),
Restaurant
.
create
({
foo
:
'two'
,
bar
:
'2'
},
{
searchPath
:
SEARCH_PATH_TWO
})
.
then
(
rnt
=>
rnt
.
update
({
bar
:
'x.2'
},
{
searchPath
:
SEARCH_PATH_TWO
}))
]).
then
(()
=>
Promise
.
all
([
Restaurant
.
findAll
({
where
:
{
bar
:
'x.1'
},
searchPath
:
SEARCH_PATH_ONE
}).
then
(
restaurantsOne
=>
{
expect
(
restaurantsOne
.
length
).
to
.
equal
(
1
);
expect
(
restaurantsOne
[
0
].
foo
).
to
.
equal
(
'one'
);
expect
(
restaurantsOne
[
0
].
bar
).
to
.
equal
(
'x.1'
);
}),
Restaurant
.
findAll
({
where
:
{
bar
:
'x.2'
},
searchPath
:
SEARCH_PATH_TWO
}).
then
(
restaurantsTwo
=>
{
expect
(
restaurantsTwo
.
length
).
to
.
equal
(
1
);
expect
(
restaurantsTwo
[
0
].
foo
).
to
.
equal
(
'two'
);
expect
(
restaurantsTwo
[
0
].
bar
).
to
.
equal
(
'x.2'
);
})
]));
});
});
});
}
});
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