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 cae6b4dd
authored
Apr 23, 2020
by
Andy Edwards
Committed by
GitHub
Apr 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(sqlite/query): simplify promise usage (#12157)
1 parent
303b453a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
22 deletions
lib/dialects/sqlite/query.js
lib/dialects/sqlite/query.js
View file @
cae6b4d
...
@@ -232,36 +232,34 @@ class Query extends AbstractQuery {
...
@@ -232,36 +232,34 @@ class Query extends AbstractQuery {
}
}
return
new
Promise
(
resolve
=>
{
return
new
Promise
(
(
resolve
,
reject
)
=>
{
const
columnTypes
=
{};
const
columnTypes
=
{};
conn
.
serialize
(()
=>
{
conn
.
serialize
(()
=>
{
const
executeSql
=
()
=>
{
const
executeSql
=
()
=>
{
if
(
sql
.
startsWith
(
'-- '
))
{
if
(
sql
.
startsWith
(
'-- '
))
{
return
resolve
();
return
resolve
();
}
}
resolve
(
new
Promise
((
resolve
,
reject
)
=>
{
const
query
=
this
;
const
query
=
this
;
// cannot use arrow function here because the function is bound to the statement
// cannot use arrow function here because the function is bound to the statement
function
afterExecute
(
executionError
,
results
)
{
function
afterExecute
(
executionError
,
results
)
{
try
{
try
{
complete
();
complete
();
// `this` is passed from sqlite, we have no control over this.
// `this` is passed from sqlite, we have no control over this.
// eslint-disable-next-line no-invalid-this
// eslint-disable-next-line no-invalid-this
resolve
(
query
.
_handleQueryResponse
(
this
,
columnTypes
,
executionError
,
results
));
resolve
(
query
.
_handleQueryResponse
(
this
,
columnTypes
,
executionError
,
results
));
return
;
return
;
}
catch
(
error
)
{
}
catch
(
error
)
{
reject
(
error
);
reject
(
error
);
}
}
}
}
if
(
method
===
'exec'
)
{
if
(
method
===
'exec'
)
{
// exec does not support bind parameter
// exec does not support bind parameter
conn
[
method
](
sql
,
afterExecute
);
conn
[
method
](
sql
,
afterExecute
);
}
else
{
}
else
{
if
(
!
parameters
)
parameters
=
[];
if
(
!
parameters
)
parameters
=
[];
conn
[
method
](
sql
,
parameters
,
afterExecute
);
conn
[
method
](
sql
,
parameters
,
afterExecute
);
}
}
}));
return
null
;
return
null
;
};
};
...
...
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