不要怂,就是干,撸起袖子干!

Commit a34399f6 by BenBenHu Committed by Sushant

feat(mariadb): support indexHints on mariadb dialect (#11573)

1 parent 2949a639
......@@ -43,6 +43,7 @@ MariadbDialect.prototype.supports = _.merge(
check: false
},
indexViaAlter: true,
indexHints: true,
NUMERIC: true,
GEOMETRY: true,
JSON: true,
......
......@@ -6,6 +6,7 @@ const chai = require('chai'),
dialect = Support.getTestDialect(),
_ = require('lodash'),
Op = require('../../../../lib/operators'),
IndexHints = require('../../../../lib/index-hints'),
QueryGenerator = require('../../../../lib/dialects/mariadb/query-generator');
if (dialect === 'mariadb') {
......@@ -764,6 +765,53 @@ if (dialect === 'mariadb') {
arguments: ['User', 'email'],
expectation: "SELECT CONSTRAINT_NAME as constraint_name,CONSTRAINT_NAME as constraintName,CONSTRAINT_SCHEMA as constraintSchema,CONSTRAINT_SCHEMA as constraintCatalog,TABLE_NAME as tableName,TABLE_SCHEMA as tableSchema,TABLE_SCHEMA as tableCatalog,COLUMN_NAME as columnName,REFERENCED_TABLE_SCHEMA as referencedTableSchema,REFERENCED_TABLE_SCHEMA as referencedTableCatalog,REFERENCED_TABLE_NAME as referencedTableName,REFERENCED_COLUMN_NAME as referencedColumnName FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE (REFERENCED_TABLE_NAME = 'User' AND REFERENCED_COLUMN_NAME = 'email') OR (TABLE_NAME = 'User' AND COLUMN_NAME = 'email' AND REFERENCED_TABLE_NAME IS NOT NULL)"
}
],
selectFromTableFragment: [
{
arguments: [{}, null, ['*'], '`Project`'],
expectation: 'SELECT * FROM `Project`'
}, {
arguments: [
{ indexHints: [{ type: IndexHints.USE, values: ['index_project_on_name'] }] },
null,
['*'],
'`Project`'
],
expectation: 'SELECT * FROM `Project` USE INDEX (`index_project_on_name`)'
}, {
arguments: [
{ indexHints: [{ type: IndexHints.FORCE, values: ['index_project_on_name'] }] },
null,
['*'],
'`Project`'
],
expectation: 'SELECT * FROM `Project` FORCE INDEX (`index_project_on_name`)'
}, {
arguments: [
{ indexHints: [{ type: IndexHints.IGNORE, values: ['index_project_on_name'] }] },
null,
['*'],
'`Project`'
],
expectation: 'SELECT * FROM `Project` IGNORE INDEX (`index_project_on_name`)'
}, {
arguments: [
{ indexHints: [{ type: IndexHints.USE, values: ['index_project_on_name', 'index_project_on_name_and_foo'] }] },
null,
['*'],
'`Project`'
],
expectation: 'SELECT * FROM `Project` USE INDEX (`index_project_on_name`,`index_project_on_name_and_foo`)'
}, {
arguments: [
{ indexHints: [{ type: 'FOO', values: ['index_project_on_name'] }] },
null,
['*'],
'`Project`'
],
expectation: 'SELECT * FROM `Project`'
}
]
};
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!