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 6132bcc5
authored
Jan 04, 2014
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
normalize start/commit/rollback query generation
1 parent
07e72bdd
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
6 additions
and
47 deletions
lib/dialects/abstract/query-generator.js
lib/dialects/mysql/query-generator.js
lib/dialects/postgres/query-generator.js
lib/dialects/sqlite/query-generator.js
test/dao-factory.test.js
lib/dialects/abstract/query-generator.js
View file @
6132bcc
...
@@ -551,7 +551,7 @@ module.exports = (function() {
...
@@ -551,7 +551,7 @@ module.exports = (function() {
* @return {String} The generated sql query.
* @return {String} The generated sql query.
*/
*/
startTransactionQuery
:
function
(
options
)
{
startTransactionQuery
:
function
(
options
)
{
throwMethodUndefined
(
'startTransactionQuery'
)
return
"START TRANSACTION;"
},
},
/**
/**
...
@@ -561,7 +561,7 @@ module.exports = (function() {
...
@@ -561,7 +561,7 @@ module.exports = (function() {
* @return {String} The generated sql query.
* @return {String} The generated sql query.
*/
*/
commitTransactionQuery
:
function
(
options
)
{
commitTransactionQuery
:
function
(
options
)
{
throwMethodUndefined
(
'commitTransactionQuery'
)
return
"COMMIT;"
},
},
/**
/**
...
@@ -571,7 +571,7 @@ module.exports = (function() {
...
@@ -571,7 +571,7 @@ module.exports = (function() {
* @return {String} The generated sql query.
* @return {String} The generated sql query.
*/
*/
rollbackTransactionQuery
:
function
(
options
)
{
rollbackTransactionQuery
:
function
(
options
)
{
throwMethodUndefined
(
'rollbackTransactionQuery'
)
return
"ROLLBACK;"
},
},
addLimitAndOffset
:
function
(
options
,
query
){
addLimitAndOffset
:
function
(
options
,
query
){
...
...
lib/dialects/mysql/query-generator.js
View file @
6132bcc
...
@@ -300,24 +300,6 @@ module.exports = (function() {
...
@@ -300,24 +300,6 @@ module.exports = (function() {
return
Utils
.
_
.
template
(
sql
)({
tableName
:
tableName
,
indexName
:
indexName
})
return
Utils
.
_
.
template
(
sql
)({
tableName
:
tableName
,
indexName
:
indexName
})
},
},
/**
* Returns a query that starts a transaction.
*
* @param {Object} options An object with options.
* @return {String} The generated sql query.
*/
startTransactionQuery
:
function
(
options
)
{
return
"START TRANSACTION;"
},
commitTransactionQuery
:
function
(
options
)
{
return
"COMMIT;"
},
rollbackTransactionQuery
:
function
(
options
)
{
return
"ROLLBACK;"
},
attributesToSQL
:
function
(
attributes
)
{
attributesToSQL
:
function
(
attributes
)
{
var
result
=
{}
var
result
=
{}
...
@@ -428,7 +410,7 @@ module.exports = (function() {
...
@@ -428,7 +410,7 @@ module.exports = (function() {
quoteIdentifiers
:
function
(
identifiers
,
force
)
{
quoteIdentifiers
:
function
(
identifiers
,
force
)
{
return
identifiers
.
split
(
'.'
).
map
(
function
(
v
)
{
return
this
.
quoteIdentifier
(
v
,
force
)
}.
bind
(
this
)).
join
(
'.'
)
return
identifiers
.
split
(
'.'
).
map
(
function
(
v
)
{
return
this
.
quoteIdentifier
(
v
,
force
)
}.
bind
(
this
)).
join
(
'.'
)
},
},
quoteTable
:
function
(
table
)
{
quoteTable
:
function
(
table
)
{
return
this
.
quoteIdentifier
(
table
)
return
this
.
quoteIdentifier
(
table
)
},
},
...
...
lib/dialects/postgres/query-generator.js
View file @
6132bcc
...
@@ -859,25 +859,7 @@ module.exports = (function() {
...
@@ -859,25 +859,7 @@ module.exports = (function() {
*/
*/
dropForeignKeyQuery
:
function
(
tableName
,
foreignKey
)
{
dropForeignKeyQuery
:
function
(
tableName
,
foreignKey
)
{
return
'ALTER TABLE '
+
this
.
quoteIdentifier
(
tableName
)
+
' DROP CONSTRAINT '
+
this
.
quoteIdentifier
(
foreignKey
)
+
';'
return
'ALTER TABLE '
+
this
.
quoteIdentifier
(
tableName
)
+
' DROP CONSTRAINT '
+
this
.
quoteIdentifier
(
foreignKey
)
+
';'
},
}
/**
* Returns a query that starts a transaction.
*
* @param {Object} options An object with options.
* @return {String} The generated sql query.
*/
startTransactionQuery
:
function
(
options
)
{
return
"START TRANSACTION;"
},
commitTransactionQuery
:
function
(
options
)
{
return
"COMMIT;"
},
rollbackTransactionQuery
:
function
(
options
)
{
return
"ROLLBACK;"
},
}
}
// Private
// Private
...
...
lib/dialects/sqlite/query-generator.js
View file @
6132bcc
...
@@ -376,10 +376,6 @@ module.exports = (function() {
...
@@ -376,10 +376,6 @@ module.exports = (function() {
})
})
},
},
startTransactionQuery
:
function
(
options
)
{
return
"BEGIN TRANSACTION;"
},
setAutocommitQuery
:
function
(
value
)
{
setAutocommitQuery
:
function
(
value
)
{
return
"-- SQLite does not support SET autocommit."
return
"-- SQLite does not support SET autocommit."
},
},
...
...
test/dao-factory.test.js
View file @
6132bcc
...
@@ -1252,7 +1252,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
...
@@ -1252,7 +1252,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}
}
})
})
it
.
only
(
"should be able to create and update records under any valid schematic"
,
function
(
done
){
it
(
"should be able to create and update records under any valid schematic"
,
function
(
done
){
var
self
=
this
var
self
=
this
self
.
UserPublic
.
sync
({
force
:
true
}).
done
(
function
(
err
,
UserPublicSync
){
self
.
UserPublic
.
sync
({
force
:
true
}).
done
(
function
(
err
,
UserPublicSync
){
...
@@ -1288,7 +1288,6 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
...
@@ -1288,7 +1288,6 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}
}
done
()
done
()
}).
error
(
function
(
err
)
{
}).
error
(
function
(
err
)
{
console
.
log
(
err
)
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
err
).
not
.
to
.
be
.
ok
})
})
})
})
...
...
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