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 23652061
authored
Mar 10, 2018
by
Varga Zsolt
Committed by
Sushant
Mar 10, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(postgresql): search path with datatypes that use dynamic oids (#9148)
1 parent
78a1fb6c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
6 deletions
lib/dialects/postgres/connection-manager.js
test/integration/model/searchPath.test.js
lib/dialects/postgres/connection-manager.js
View file @
2365206
...
@@ -208,7 +208,16 @@ class ConnectionManager extends AbstractConnectionManager {
...
@@ -208,7 +208,16 @@ class ConnectionManager extends AbstractConnectionManager {
return
(
connection
||
this
.
sequelize
).
query
(
return
(
connection
||
this
.
sequelize
).
query
(
"SELECT typname, typtype, oid, typarray FROM pg_type WHERE (typtype = 'b' AND typname IN ('hstore', 'geometry', 'geography')) OR (typtype = 'e')"
"SELECT typname, typtype, oid, typarray FROM pg_type WHERE (typtype = 'b' AND typname IN ('hstore', 'geometry', 'geography')) OR (typtype = 'e')"
).
then
(
results
=>
{
).
then
(
results
=>
{
const
result
=
Array
.
isArray
(
results
)
?
results
.
pop
()
:
results
;
let
result
=
Array
.
isArray
(
results
)
?
results
.
pop
()
:
results
;
// When searchPath is prepended then two statements are executed and the result is
// an array of those two statements. First one is the SET search_path and second is
// the SELECT query result.
if
(
Array
.
isArray
(
result
))
{
if
(
result
[
0
].
command
===
'SET'
)
{
result
=
result
.
pop
();
}
}
// Reset OID mapping for dynamic type
// Reset OID mapping for dynamic type
[
[
...
...
test/integration/model/searchPath.test.js
View file @
2365206
...
@@ -18,7 +18,6 @@ let locationId;
...
@@ -18,7 +18,6 @@ let locationId;
describe
(
Support
.
getTestDialectTeaser
(
'Model'
),
()
=>
{
describe
(
Support
.
getTestDialectTeaser
(
'Model'
),
()
=>
{
if
(
current
.
dialect
.
supports
.
searchPath
)
{
if
(
current
.
dialect
.
supports
.
searchPath
)
{
describe
(
'SEARCH PATH'
,
()
=>
{
describe
(
'SEARCH PATH'
,
()
=>
{
before
(
function
()
{
before
(
function
()
{
this
.
Restaurant
=
current
.
define
(
'restaurant'
,
{
this
.
Restaurant
=
current
.
define
(
'restaurant'
,
{
...
@@ -27,7 +26,8 @@ describe(Support.getTestDialectTeaser('Model'), () => {
...
@@ -27,7 +26,8 @@ describe(Support.getTestDialectTeaser('Model'), () => {
},
},
{
tableName
:
'restaurants'
});
{
tableName
:
'restaurants'
});
this
.
Location
=
current
.
define
(
'location'
,
{
this
.
Location
=
current
.
define
(
'location'
,
{
name
:
DataTypes
.
STRING
name
:
DataTypes
.
STRING
,
type
:
DataTypes
.
ENUM
(
'a'
,
'b'
)
},
},
{
tableName
:
'locations'
});
{
tableName
:
'locations'
});
this
.
Employee
=
current
.
define
(
'employee'
,
{
this
.
Employee
=
current
.
define
(
'employee'
,
{
...
@@ -51,7 +51,6 @@ describe(Support.getTestDialectTeaser('Model'), () => {
...
@@ -51,7 +51,6 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});
});
});
});
beforeEach
(
'build restaurant tables'
,
function
()
{
beforeEach
(
'build restaurant tables'
,
function
()
{
const
Restaurant
=
this
.
Restaurant
;
const
Restaurant
=
this
.
Restaurant
;
return
current
.
createSchema
(
'schema_one'
).
then
(()
=>
{
return
current
.
createSchema
(
'schema_one'
).
then
(()
=>
{
...
@@ -71,6 +70,12 @@ describe(Support.getTestDialectTeaser('Model'), () => {
...
@@ -71,6 +70,12 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});
});
});
});
describe
(
'enum case'
,
()
=>
{
it
(
'able to refresh enum when searchPath is used'
,
function
()
{
return
this
.
Location
.
sync
({
force
:
true
});
});
});
describe
(
'Add data via model.create, retrieve via model.findOne'
,
()
=>
{
describe
(
'Add data via model.create, retrieve via model.findOne'
,
()
=>
{
it
(
'should be able to insert data into the table in schema_one using create'
,
function
()
{
it
(
'should be able to insert data into the table in schema_one using create'
,
function
()
{
const
Restaurant
=
this
.
Restaurant
;
const
Restaurant
=
this
.
Restaurant
;
...
@@ -292,7 +297,6 @@ describe(Support.getTestDialectTeaser('Model'), () => {
...
@@ -292,7 +297,6 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});
});
});
});
it
(
'should be able to insert and retrieve associated data into the table in schema_two'
,
function
()
{
it
(
'should be able to insert and retrieve associated data into the table in schema_two'
,
function
()
{
const
Restaurant
=
this
.
Restaurant
;
const
Restaurant
=
this
.
Restaurant
;
const
Location
=
this
.
Location
;
const
Location
=
this
.
Location
;
...
@@ -379,7 +383,6 @@ describe(Support.getTestDialectTeaser('Model'), () => {
...
@@ -379,7 +383,6 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});
});
});
});
it
(
'should be able to insert and retrieve associated data into the table in schema_two'
,
function
()
{
it
(
'should be able to insert and retrieve associated data into the table in schema_two'
,
function
()
{
const
Restaurant
=
this
.
Restaurant
;
const
Restaurant
=
this
.
Restaurant
;
const
Employee
=
this
.
Employee
;
const
Employee
=
this
.
Employee
;
...
...
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