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 839f1a97
authored
May 08, 2020
by
SuHun Han
Committed by
GitHub
May 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(query-interface): allow sequelize.fn and sequelize.literal in fields of IndexesOptions (#12224)
1 parent
2fa578ea
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
types/lib/query-interface.d.ts
types/test/query-interface.ts
types/lib/query-interface.d.ts
View file @
839f1a9
...
...
@@ -4,6 +4,7 @@ import QueryTypes = require('./query-types');
import
{
Sequelize
,
RetryOptions
}
from
'./sequelize'
;
import
{
Transaction
}
from
'./transaction'
;
import
{
SetRequired
}
from
'./../type-helpers/set-required'
;
import
{
Fn
,
Literal
}
from
'./utils'
;
type
BindOrReplacements
=
{
[
key
:
string
]:
unknown
}
|
unknown
[];
type
FieldMap
=
{
[
key
:
string
]:
string
};
...
...
@@ -172,7 +173,7 @@ export interface IndexesOptions {
* (field name), `length` (create a prefix index of length chars), `order` (the direction the column
* should be sorted in), `collate` (the collation (sort order) for the column), `operator` (likes IndexesOptions['operator'])
*/
fields
?:
(
string
|
{
name
:
string
;
length
?:
number
;
order
?:
'ASC'
|
'DESC'
;
collate
?:
string
;
operator
?:
string
})[];
fields
?:
(
string
|
{
name
:
string
;
length
?:
number
;
order
?:
'ASC'
|
'DESC'
;
collate
?:
string
;
operator
?:
string
}
|
Fn
|
Literal
)[];
/**
* The method to create the index by (`USING` statement in SQL). BTREE and HASH are supported by mysql and
...
...
types/test/query-interface.ts
View file @
839f1a9
import
{
DataTypes
,
Model
}
from
'sequelize'
;
import
{
DataTypes
,
Model
,
fn
,
literal
,
col
}
from
'sequelize'
;
// tslint:disable-next-line:no-submodule-imports
import
{
QueryInterface
}
from
'sequelize/lib/query-interface'
;
...
...
@@ -154,6 +154,20 @@ queryInterface.addIndex('Foo', {
],
});
queryInterface
.
addIndex
(
'Foo'
,
{
name
:
'foo_b_lower'
,
fields
:
[
fn
(
'lower'
,
col
(
'foo_b'
))
],
});
queryInterface
.
addIndex
(
'Foo'
,
{
name
:
'foo_c_lower'
,
fields
:
[
literal
(
'LOWER(foo_c)'
)
]
})
queryInterface
.
removeIndex
(
'Person'
,
'SuperDuperIndex'
);
// or
...
...
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