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 525b6170
authored
Dec 04, 2014
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(query-interface): add schema support to createTable()
1 parent
8c482bfe
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
3 deletions
lib/dialects/abstract/query-generator.js
lib/query-interface.js
test/query-interface.test.js
lib/dialects/abstract/query-generator.js
View file @
525b617
...
...
@@ -10,7 +10,7 @@ module.exports = (function() {
var
QueryGenerator
=
{
addSchema
:
function
(
param
)
{
var
self
=
this
,
schema
=
(
param
.
options
&&
param
.
options
.
schema
?
param
.
options
.
schema
:
undefined
)
,
schema
=
(
!
param
.
options
&&
param
.
schema
)
||
(
param
.
options
&&
param
.
options
.
schema
?
param
.
options
.
schema
:
undefined
)
,
schemaDelimiter
=
(
param
.
options
&&
param
.
options
.
schemaDelimiter
?
param
.
options
.
schemaDelimiter
:
undefined
);
if
(
!
schema
)
return
param
.
tableName
||
param
;
...
...
lib/query-interface.js
View file @
525b617
...
...
@@ -133,6 +133,13 @@ module.exports = (function() {
}
}
if
(
options
.
schema
)
{
tableName
=
self
.
QueryGenerator
.
addSchema
({
tableName
:
tableName
,
schema
:
options
.
schema
});
}
attributes
=
self
.
QueryGenerator
.
attributesToSQL
(
attributes
,
{
context
:
'createTable'
});
...
...
@@ -665,6 +672,13 @@ module.exports = (function() {
};
QueryInterface
.
prototype
.
rawSelect
=
function
(
tableName
,
options
,
attributeSelector
,
Model
)
{
if
(
options
.
schema
)
{
tableName
=
this
.
QueryGenerator
.
addSchema
({
tableName
:
tableName
,
schema
:
options
.
schema
});
}
var
sql
=
this
.
QueryGenerator
.
selectQuery
(
tableName
,
options
,
Model
)
,
queryOptions
=
Utils
.
_
.
extend
({
transaction
:
options
.
transaction
},
{
plain
:
true
,
raw
:
true
,
type
:
QueryTypes
.
SELECT
})
,
self
=
this
;
...
...
test/query-interface.test.js
View file @
525b617
...
...
@@ -161,8 +161,27 @@ describe(Support.getTestDialectTeaser("QueryInterface"), function () {
type
:
DataTypes
.
ENUM
,
values
:
[
'value1'
,
'value2'
,
'value3'
]
}
})
})
});
});
it
(
'should work with schemas'
,
function
()
{
var
self
=
this
;
return
self
.
sequelize
.
dropAllSchemas
().
then
(
function
()
{
return
self
.
sequelize
.
createSchema
(
"hero"
);
}).
then
(
function
()
{
return
self
.
queryInterface
.
createTable
(
'User'
,
{
name
:
{
type
:
DataTypes
.
STRING
}
},
{
schema
:
'hero'
});
}).
then
(
function
()
{
return
self
.
queryInterface
.
rawSelect
(
'User'
,
{
schema
:
'hero'
},
'name'
);
});
});
})
describe
(
'renameColumn'
,
function
()
{
...
...
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