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 d2f0641c
authored
May 12, 2015
by
Mike Groseclose
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix showIndexQuery so appropriate indexes are returned when a schema is used
1 parent
a73e3b74
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
0 deletions
changelog.md
lib/dialects/postgres/query-generator.js
test/integration/query-interface.test.js
changelog.md
View file @
d2f0641
# Next
# Next
-
[
BUG
]
fix showIndexQuery so appropriate indexes are returned when a schema is used
-
[
BUG
]
Fix addIndexQuery error when the model has a schema
-
[
BUG
]
Fix addIndexQuery error when the model has a schema
# 2.1.3
# 2.1.3
...
...
lib/dialects/postgres/query-generator.js
View file @
d2f0641
...
@@ -426,6 +426,10 @@ module.exports = (function() {
...
@@ -426,6 +426,10 @@ module.exports = (function() {
},
},
showIndexesQuery
:
function
(
tableName
)
{
showIndexesQuery
:
function
(
tableName
)
{
if
(
!
Utils
.
_
.
isString
(
tableName
))
{
tableName
=
tableName
.
tableName
;
}
// This is ARCANE!
// This is ARCANE!
var
query
=
'SELECT i.relname AS name, ix.indisprimary AS primary, ix.indisunique AS unique, ix.indkey AS indkey, '
+
var
query
=
'SELECT i.relname AS name, ix.indisprimary AS primary, ix.indisunique AS unique, ix.indkey AS indkey, '
+
'array_agg(a.attnum) as column_indexes, array_agg(a.attname) AS column_names, pg_get_indexdef(ix.indexrelid) '
+
'array_agg(a.attnum) as column_indexes, array_agg(a.attname) AS column_names, pg_get_indexdef(ix.indexrelid) '
+
...
...
test/integration/query-interface.test.js
View file @
d2f0641
...
@@ -107,6 +107,39 @@ describe(Support.getTestDialectTeaser('QueryInterface'), function() {
...
@@ -107,6 +107,39 @@ describe(Support.getTestDialectTeaser('QueryInterface'), function() {
});
});
});
});
it
(
'works with schemas'
,
function
()
{
var
self
=
this
;
return
self
.
sequelize
.
dropAllSchemas
({
logging
:
log
}).
then
(
function
()
{
return
self
.
sequelize
.
createSchema
(
'schema'
,
{
logging
:
log
});
}).
then
(
function
()
{
return
self
.
queryInterface
.
createTable
(
'table'
,
{
name
:
{
type
:
DataTypes
.
STRING
},
isAdmin
:
{
type
:
DataTypes
.
STRING
}
},
{
schema
:
'schema'
});
}).
then
(
function
()
{
return
self
.
queryInterface
.
addIndex
({
schema
:
'schema'
,
tableName
:
'table'
},
[
'name'
,
'isAdmin'
],
{
logging
:
log
},
'schema_table'
).
then
(
function
()
{
return
self
.
queryInterface
.
showIndex
({
schema
:
'schema'
,
tableName
:
'table'
},
{
logging
:
log
}).
then
(
function
(
indexes
)
{
expect
(
indexes
.
length
).
to
.
eq
(
1
);
count
=
0
;
});
});
});
});
it
(
'does not fail on reserved keywords'
,
function
()
{
it
(
'does not fail on reserved keywords'
,
function
()
{
return
this
.
queryInterface
.
addIndex
(
'Group'
,
[
'from'
]);
return
this
.
queryInterface
.
addIndex
(
'Group'
,
[
'from'
]);
});
});
...
...
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