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 89c2211d
authored
Dec 14, 2011
by
sdepold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extracted showTablesQuery
1 parent
8c519107
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
6 deletions
lib/connectors/mysql/query-generator.js
lib/connectors/query-generator.js
lib/query-interface.js
lib/connectors/mysql/query-generator.js
View file @
89c2211
...
@@ -43,6 +43,10 @@ module.exports = (function() {
...
@@ -43,6 +43,10 @@ module.exports = (function() {
return
Utils
.
_
.
template
(
query
)({
before
:
before
,
after
:
after
})
return
Utils
.
_
.
template
(
query
)({
before
:
before
,
after
:
after
})
},
},
showTablesQuery
:
function
()
{
return
'SHOW TABLES;'
},
addColumnQuery
:
function
(
tableName
,
attributes
)
{
addColumnQuery
:
function
(
tableName
,
attributes
)
{
var
query
=
"ALTER TABLE `<%= tableName %>` ADD <%= attributes %>;"
var
query
=
"ALTER TABLE `<%= tableName %>` ADD <%= attributes %>;"
,
attrString
=
Utils
.
_
.
map
(
attributes
,
function
(
definition
,
attributeName
)
{
,
attrString
=
Utils
.
_
.
map
(
attributes
,
function
(
definition
,
attributeName
)
{
...
...
lib/connectors/query-generator.js
View file @
89c2211
...
@@ -26,6 +26,13 @@ module.exports = (function() {
...
@@ -26,6 +26,13 @@ module.exports = (function() {
},
},
/*
/*
Returns a query, which gets all available table names in the database.
*/
showTablesQuery
:
function
()
{
throwMethodUndefined
(
'showTablesQuery'
)
},
/*
Returns a query, which adds an attribute to an existing table.
Returns a query, which adds an attribute to an existing table.
Parameters:
Parameters:
- tableName: Name of the existing table.
- tableName: Name of the existing table.
...
@@ -194,7 +201,7 @@ module.exports = (function() {
...
@@ -194,7 +201,7 @@ module.exports = (function() {
}
}
var
throwMethodUndefined
=
function
(
methodName
)
{
var
throwMethodUndefined
=
function
(
methodName
)
{
throw
new
Error
(
'The method "'
+
methodName
+
'"
was not defined!
'
)
throw
new
Error
(
'The method "'
+
methodName
+
'"
is not defined! Please add it to your sql dialect.
'
)
}
}
return
QueryGenerator
return
QueryGenerator
...
...
lib/query-interface.js
View file @
89c2211
...
@@ -54,11 +54,8 @@ module.exports = (function() {
...
@@ -54,11 +54,8 @@ module.exports = (function() {
var
self
=
this
var
self
=
this
return
new
Utils
.
CustomEventEmitter
(
function
(
emitter
)
{
return
new
Utils
.
CustomEventEmitter
(
function
(
emitter
)
{
self
.
sequelize
.
query
(
'SHOW TABLES;'
,
null
,
{
raw
:
true
}).
success
(
function
(
data
)
{
var
showTablesSql
=
self
.
QueryGenerator
.
showTablesQuery
()
var
tableNames
=
Sequelize
.
Utils
.
_
.
map
(
data
,
function
(
hash
)
{
self
.
sequelize
.
query
(
showTablesSql
,
null
,
{
raw
:
true
}).
success
(
function
(
tableNames
)
{
return
Sequelize
.
Utils
.
_
.
values
(
hash
)
})
self
.
emit
(
'showAllTables'
,
null
)
self
.
emit
(
'showAllTables'
,
null
)
emitter
.
emit
(
'success'
,
Sequelize
.
Utils
.
_
.
flatten
(
tableNames
))
emitter
.
emit
(
'success'
,
Sequelize
.
Utils
.
_
.
flatten
(
tableNames
))
}).
error
(
function
(
err
)
{
}).
error
(
function
(
err
)
{
...
...
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