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 1cfbd333
authored
Jun 26, 2021
by
Nicolas Padula
Committed by
GitHub
Jun 26, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(data-types): use proper field name for `ARRAY(ENUM)` (#13210)
1 parent
444f06f5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
1 deletions
lib/dialects/postgres/data-types.js
test/integration/dialects/postgres/dao.test.js
lib/dialects/postgres/data-types.js
View file @
1cfbd33
...
@@ -480,7 +480,7 @@ module.exports = BaseTypes => {
...
@@ -480,7 +480,7 @@ module.exports = BaseTypes => {
if
(
this
.
type
instanceof
BaseTypes
.
ENUM
)
{
if
(
this
.
type
instanceof
BaseTypes
.
ENUM
)
{
castKey
=
`
${
Utils
.
addTicks
(
castKey
=
`
${
Utils
.
addTicks
(
Utils
.
generateEnumName
(
options
.
field
.
Model
.
getTableName
(),
options
.
field
.
field
Name
),
Utils
.
generateEnumName
(
options
.
field
.
Model
.
getTableName
(),
options
.
field
.
field
),
'"'
'"'
)
}
[]`
;
)
}
[]`
;
}
}
...
...
test/integration/dialects/postgres/dao.test.js
View file @
1cfbd33
...
@@ -437,6 +437,34 @@ if (dialect.match(/^postgres/)) {
...
@@ -437,6 +437,34 @@ if (dialect.match(/^postgres/)) {
expect
(
user
.
permissions
).
to
.
deep
.
equal
([
'access'
,
'write'
]);
expect
(
user
.
permissions
).
to
.
deep
.
equal
([
'access'
,
'write'
]);
});
});
it
(
'should be able to insert a new record even with a redefined field name'
,
async
function
()
{
const
User
=
this
.
sequelize
.
define
(
'UserEnums'
,
{
name
:
DataTypes
.
STRING
,
type
:
DataTypes
.
ENUM
(
'A'
,
'B'
,
'C'
),
owners
:
DataTypes
.
ARRAY
(
DataTypes
.
STRING
),
specialPermissions
:
{
type
:
DataTypes
.
ARRAY
(
DataTypes
.
ENUM
([
'access'
,
'write'
,
'check'
,
'delete'
])),
field
:
'special_permissions'
}
});
await
User
.
sync
({
force
:
true
});
const
user
=
await
User
.
bulkCreate
([{
name
:
'file.exe'
,
type
:
'C'
,
owners
:
[
'userA'
,
'userB'
],
specialPermissions
:
[
'access'
,
'write'
]
}]);
expect
(
user
.
length
).
to
.
equal
(
1
);
});
it
(
'should fail when trying to insert foreign element on ARRAY(ENUM)'
,
async
function
()
{
it
(
'should fail when trying to insert foreign element on ARRAY(ENUM)'
,
async
function
()
{
const
User
=
this
.
sequelize
.
define
(
'UserEnums'
,
{
const
User
=
this
.
sequelize
.
define
(
'UserEnums'
,
{
name
:
DataTypes
.
STRING
,
name
:
DataTypes
.
STRING
,
...
...
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