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 8b53f721
authored
Sep 19, 2019
by
João Eiras
Committed by
Sushant
Sep 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(showTablesQuery): ignore views for mssql/mysql (#11439)
1 parent
992ddf75
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
3 deletions
lib/dialects/mssql/query-generator.js
lib/dialects/mysql/query-generator.js
test/integration/query-interface.test.js
test/unit/dialects/mssql/query-generator.test.js
lib/dialects/mssql/query-generator.js
View file @
8b53f72
...
...
@@ -222,7 +222,7 @@ class MSSQLQueryGenerator extends AbstractQueryGenerator {
}
showTablesQuery
()
{
return
'SELECT TABLE_NAME, TABLE_SCHEMA FROM INFORMATION_SCHEMA.TABLES;'
;
return
"SELECT TABLE_NAME, TABLE_SCHEMA FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE';"
;
}
dropTableQuery
(
tableName
)
{
...
...
lib/dialects/mysql/query-generator.js
View file @
8b53f72
...
...
@@ -149,7 +149,7 @@ class MySQLQueryGenerator extends AbstractQueryGenerator {
}
showTablesQuery
()
{
return
'SHOW TABLES;'
;
return
"SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE';"
;
}
addColumnQuery
(
table
,
key
,
dataType
)
{
...
...
test/integration/query-interface.test.js
View file @
8b53f72
...
...
@@ -41,6 +41,30 @@ describe(Support.getTestDialectTeaser('QueryInterface'), () => {
});
});
describe
(
'showAllTables'
,
()
=>
{
it
(
'should not contain views'
,
function
()
{
const
cleanup
=
()
=>
{
// NOTE: The syntax "DROP VIEW [IF EXISTS]"" is not part of the standard
// and might not be available on all RDBMSs. Therefore "DROP VIEW" is
// the compatible option, which can throw an error in case the VIEW does
// not exist. In case of error, it is ignored by reflect()+tap().
return
this
.
sequelize
.
query
(
'DROP VIEW V_Fail'
).
reflect
();
};
return
this
.
queryInterface
.
createTable
(
'my_test_table'
,
{
name
:
DataTypes
.
STRING
})
.
tap
(
cleanup
)
.
then
(()
=>
this
.
sequelize
.
query
(
'CREATE VIEW V_Fail AS SELECT 1 Id'
))
.
then
(()
=>
this
.
queryInterface
.
showAllTables
())
.
tap
(
cleanup
)
.
then
(
tableNames
=>
{
if
(
tableNames
[
0
]
&&
tableNames
[
0
].
tableName
)
{
tableNames
=
tableNames
.
map
(
v
=>
v
.
tableName
);
}
expect
(
tableNames
).
to
.
deep
.
equal
([
'my_test_table'
]);
});
});
});
describe
(
'renameTable'
,
()
=>
{
it
(
'should rename table'
,
function
()
{
return
this
.
queryInterface
...
...
test/unit/dialects/mssql/query-generator.test.js
View file @
8b53f72
...
...
@@ -183,7 +183,7 @@ if (current.dialect.name === 'mssql') {
it
(
'showTablesQuery'
,
function
()
{
expectsql
(
this
.
queryGenerator
.
showTablesQuery
(),
{
mssql
:
'SELECT TABLE_NAME, TABLE_SCHEMA FROM INFORMATION_SCHEMA.TABLES;'
mssql
:
"SELECT TABLE_NAME, TABLE_SCHEMA FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE';"
});
});
...
...
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