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 c6e41928
authored
Jun 23, 2020
by
Rémi Weislinger
Committed by
GitHub
Jun 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(postgres): parse enums correctly when describing a table (#12409)
1 parent
e33d2bdc
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
1 deletions
lib/dialects/postgres/query-generator.js
test/unit/dialects/postgres/query-generator.test.js
lib/dialects/postgres/query-generator.js
View file @
c6e4192
...
@@ -798,7 +798,7 @@ class PostgresQueryGenerator extends AbstractQueryGenerator {
...
@@ -798,7 +798,7 @@ class PostgresQueryGenerator extends AbstractQueryGenerator {
return
[];
return
[];
}
}
matches
=
matches
.
map
(
m
=>
m
.
replace
(
/",$/
,
''
).
replace
(
/,$/
,
''
).
replace
(
/
(
^"|"$
)
/
,
''
));
matches
=
matches
.
map
(
m
=>
m
.
replace
(
/",$/
,
''
).
replace
(
/,$/
,
''
).
replace
(
/
(
^"|"$
)
/
g
,
''
));
return
matches
.
slice
(
0
,
-
1
);
return
matches
.
slice
(
0
,
-
1
);
}
}
...
...
test/unit/dialects/postgres/query-generator.test.js
View file @
c6e4192
...
@@ -1265,5 +1265,45 @@ if (dialect.startsWith('postgres')) {
...
@@ -1265,5 +1265,45 @@ if (dialect.startsWith('postgres')) {
});
});
});
});
});
});
describe
(
'fromArray()'
,
()
=>
{
beforeEach
(
function
()
{
this
.
queryGenerator
=
new
QueryGenerator
({
sequelize
:
this
.
sequelize
,
_dialect
:
this
.
sequelize
.
dialect
});
});
const
tests
=
[
{
title
:
'should convert an enum with no quoted strings to an array'
,
arguments
:
'{foo,bar,foobar}'
,
expectation
:
[
'foo'
,
'bar'
,
'foobar'
]
},
{
title
:
'should convert an enum starting with a quoted string to an array'
,
arguments
:
'{"foo bar",foo,bar}'
,
expectation
:
[
'foo bar'
,
'foo'
,
'bar'
]
},
{
title
:
'should convert an enum ending with a quoted string to an array'
,
arguments
:
'{foo,bar,"foo bar"}'
,
expectation
:
[
'foo'
,
'bar'
,
'foo bar'
]
},
{
title
:
'should convert an enum with a quoted string in the middle to an array'
,
arguments
:
'{foo,"foo bar",bar}'
,
expectation
:
[
'foo'
,
'foo bar'
,
'bar'
]
},
{
title
:
'should convert an enum full of quoted strings to an array'
,
arguments
:
'{"foo bar","foo bar","foo bar"}'
,
expectation
:
[
'foo bar'
,
'foo bar'
,
'foo bar'
]
}
];
_
.
each
(
tests
,
test
=>
{
it
(
test
.
title
,
function
()
{
const
convertedText
=
this
.
queryGenerator
.
fromArray
(
test
.
arguments
);
expect
(
convertedText
).
to
.
deep
.
equal
(
test
.
expectation
);
});
});
});
});
});
}
}
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