Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
0b50739e
Unverified
Commit
0b50739e
authored
Jul 19, 2017
by
Luís Cobucci
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable JSONB when the new JSON is used too
parent
31d01283
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
18 deletions
+31
-18
PostgreSqlSchemaManager.php
lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
+1
-1
PostgreSqlSchemaManagerTest.php
...ts/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php
+17
-6
PostgreSQLSchemaManagerTest.php
...octrine/Tests/DBAL/Schema/PostgreSQLSchemaManagerTest.php
+13
-11
No files found.
lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
View file @
0b50739e
...
...
@@ -444,7 +444,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
$column
->
setPlatformOption
(
'collation'
,
$tableColumn
[
'collation'
]);
}
if
(
$column
->
getType
()
->
getName
()
===
'json_array'
)
{
if
(
in_array
(
$column
->
getType
()
->
getName
(),
[
Type
::
JSON_ARRAY
,
Type
::
JSON
],
true
)
)
{
$column
->
setPlatformOption
(
'jsonb'
,
$jsonb
);
}
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php
View file @
0b50739e
...
...
@@ -28,7 +28,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$params
=
$this
->
_conn
->
getParams
();
$paths
=
$this
->
_sm
->
getSchemaSearchPaths
();
$this
->
assertEquals
(
array
(
$params
[
'user'
],
'public'
)
,
$paths
);
$this
->
assertEquals
(
[
$params
[
'user'
],
'public'
]
,
$paths
);
}
/**
...
...
@@ -40,7 +40,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$this
->
assertInternalType
(
'array'
,
$names
);
$this
->
assertTrue
(
count
(
$names
)
>
0
);
$this
->
assert
True
(
in_array
(
'public'
,
$names
),
"The public schema should be found."
);
$this
->
assert
Contains
(
'public'
,
$names
,
'The public schema should be found.'
);
}
/**
...
...
@@ -366,7 +366,10 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$this
->
assertSame
(
'(id IS NULL)'
,
$onlineTable
->
getIndex
(
'simple_partial_index'
)
->
getOption
(
'where'
));
}
public
function
testJsonbColumn
()
/**
* @dataProvider jsonbColumnTypeProvider
*/
public
function
testJsonbColumn
(
string
$type
)
:
void
{
if
(
!
$this
->
_sm
->
getDatabasePlatform
()
instanceof
PostgreSQL94Platform
)
{
$this
->
markTestSkipped
(
"Requires PostgresSQL 9.4+"
);
...
...
@@ -374,14 +377,22 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
}
$table
=
new
Schema\Table
(
'test_jsonb'
);
$table
->
addColumn
(
'foo'
,
'json_array'
)
->
setPlatformOption
(
'jsonb'
,
true
);
$table
->
addColumn
(
'foo'
,
$type
)
->
setPlatformOption
(
'jsonb'
,
true
);
$this
->
_sm
->
dropAndCreateTable
(
$table
);
/** @var Schema\Column[] $columns */
$columns
=
$this
->
_sm
->
listTableColumns
(
'test_jsonb'
);
$this
->
assertEquals
(
'json_array'
,
$columns
[
'foo'
]
->
getType
()
->
getName
());
$this
->
assertEquals
(
true
,
$columns
[
'foo'
]
->
getPlatformOption
(
'jsonb'
));
$this
->
assertSame
(
TYPE
::
JSON
,
$columns
[
'foo'
]
->
getType
()
->
getName
());
$this
->
assertTrue
(
true
,
$columns
[
'foo'
]
->
getPlatformOption
(
'jsonb'
));
}
public
function
jsonbColumnTypeProvider
()
:
array
{
return
[
[
Type
::
JSON
],
[
Type
::
JSON_ARRAY
],
];
}
/**
...
...
tests/Doctrine/Tests/DBAL/Schema/PostgreSQLSchemaManagerTest.php
View file @
0b50739e
...
...
@@ -22,9 +22,11 @@ class PostgreSQLSchemaManagerTest extends \PHPUnit_Framework_TestCase
{
$driverMock
=
$this
->
createMock
(
'Doctrine\DBAL\Driver'
);
$platform
=
$this
->
createMock
(
'Doctrine\DBAL\Platforms\PostgreSqlPlatform'
);
$this
->
connection
=
$this
->
getMockBuilder
(
'Doctrine\DBAL\Connection'
)
->
setConstructorArgs
(
array
(
array
(
'platform'
=>
$platform
),
$driverMock
)
)
->
setConstructorArgs
(
[[
'platform'
=>
$platform
],
$driverMock
]
)
->
getMock
();
$this
->
schemaManager
=
new
PostgreSqlSchemaManager
(
$this
->
connection
,
$platform
);
}
...
...
@@ -36,12 +38,12 @@ class PostgreSQLSchemaManagerTest extends \PHPUnit_Framework_TestCase
$configuration
=
new
Configuration
();
$configuration
->
setFilterSchemaAssetsExpression
(
'/^schema/'
);
$sequences
=
array
(
array
(
'relname'
=>
'foo'
,
'schemaname'
=>
'schema'
)
,
array
(
'relname'
=>
'bar'
,
'schemaname'
=>
'schema'
)
,
array
(
'relname'
=>
'baz'
,
'schemaname'
=>
''
)
,
array
(
'relname'
=>
'bloo'
,
'schemaname'
=>
'bloo_schema'
)
,
)
;
$sequences
=
[
[
'relname'
=>
'foo'
,
'schemaname'
=>
'schema'
]
,
[
'relname'
=>
'bar'
,
'schemaname'
=>
'schema'
]
,
[
'relname'
=>
'baz'
,
'schemaname'
=>
''
]
,
[
'relname'
=>
'bloo'
,
'schemaname'
=>
'bloo_schema'
]
,
]
;
$this
->
connection
->
expects
(
$this
->
any
())
->
method
(
'getConfiguration'
)
...
...
@@ -53,20 +55,20 @@ class PostgreSQLSchemaManagerTest extends \PHPUnit_Framework_TestCase
$this
->
connection
->
expects
(
$this
->
at
(
1
))
->
method
(
'fetchAll'
)
->
will
(
$this
->
returnValue
(
array
(
array
(
'min_value'
=>
1
,
'increment_by'
=>
1
))
));
->
will
(
$this
->
returnValue
(
[[
'min_value'
=>
1
,
'increment_by'
=>
1
]]
));
$this
->
connection
->
expects
(
$this
->
at
(
2
))
->
method
(
'fetchAll'
)
->
will
(
$this
->
returnValue
(
array
(
array
(
'min_value'
=>
2
,
'increment_by'
=>
2
))
));
->
will
(
$this
->
returnValue
(
[[
'min_value'
=>
2
,
'increment_by'
=>
2
]]
));
$this
->
connection
->
expects
(
$this
->
exactly
(
3
))
->
method
(
'fetchAll'
);
$this
->
assertEquals
(
array
(
[
new
Sequence
(
'schema.foo'
,
2
,
2
),
new
Sequence
(
'schema.bar'
,
1
,
1
),
)
,
]
,
$this
->
schemaManager
->
listSequences
(
'database'
)
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment