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 2391d082
authored
Jun 24, 2020
by
Davide Mauri
Committed by
GitHub
Jun 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(sequelize): allow passing dialectOptions.options from url (#12412)
1 parent
8477b071
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
lib/sequelize.js
test/unit/configuration.test.js
lib/sequelize.js
View file @
2391d08
...
...
@@ -212,10 +212,20 @@ class Sequelize {
}
if
(
urlParts
.
query
)
{
if
(
options
.
dialectOptions
)
if
(
options
.
dialectOptions
)
{
Object
.
assign
(
options
.
dialectOptions
,
urlParts
.
query
);
else
}
else
{
options
.
dialectOptions
=
urlParts
.
query
;
if
(
urlParts
.
query
.
options
)
{
try
{
const
o
=
JSON
.
parse
(
urlParts
.
query
.
options
);
options
.
dialectOptions
.
options
=
o
;
}
catch
(
e
)
{
// Nothing to do, string is not a valid JSON
// an thus does not need any further processing
}
}
}
}
}
else
{
// new Sequelize(database, username, password, { ... options })
...
...
test/unit/configuration.test.js
View file @
2391d08
...
...
@@ -179,5 +179,11 @@ describe('Sequelize', () => {
expect
(
dialectOptions
.
application_name
).
to
.
equal
(
'client'
);
expect
(
dialectOptions
.
ssl
).
to
.
equal
(
'true'
);
});
it
(
'should handle JSON options'
,
()
=>
{
const
sequelizeWithOptions
=
new
Sequelize
(
'mysql://example.com:9821/dbname?options={"encrypt":true}&anotherOption=1'
);
expect
(
sequelizeWithOptions
.
options
.
dialectOptions
.
options
.
encrypt
).
to
.
be
.
true
;
expect
(
sequelizeWithOptions
.
options
.
dialectOptions
.
anotherOption
).
to
.
equal
(
'1'
);
});
});
});
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