Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[DBAL-630] Incorrect PostgreSQL boolean handling #564

Closed
wants to merge 13 commits into from

6 participants

@davividal

Working on PostgreSQL incorrect boolean handling when emulating prepared statements

@doctrinebot
Collaborator

Hello,

thank you for creating this pull request. I have automatically opened an issue
on our Jira Bug Tracker for you. See the issue link:

http://www.doctrine-project.org/jira/browse/DBAL-863

We use Jira to track the state of pull requests and the versions they got
included in.

@davividal

The only issue with this PR is that it breaks Doctrine2 ORM. I already have a patch for that too, but I'm not sure on how to proceed.

lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
((9 lines not shown))
* @return mixed
*/
- public function convertBooleans($item)
+ public function convertBoolToSqlLiteral($item)
@deeky666 Collaborator
deeky666 added a note

Please don't change the public API here, this breaks BC and is unacceptable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
@@ -2367,6 +2369,18 @@ public function convertBooleans($item)
}
/**
+ * This method should handle the prepared statements case. When there is no
+ * distinction, it's OK to use the same method.
+ *
+ * @param mixed $item
+ * @return mixed
+ */
+ public function convertBoolToDbValue($item)
+ {
+ return self::convertBooleans($item);
@stof
stof added a note

please use $this->, not self:: as you are refering to an instance method, not to a static method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
@@ -2367,6 +2369,18 @@ public function convertBooleans($item)
}
/**
+ * This method should handle the prepared statements case. When there is no
+ * distinction, it's OK to use the same method.
+ *
+ * @param mixed $item
+ * @return mixed
+ */
+ public function convertBoolToDbValue($item)
@stof
stof added a note

please use booleans, not bool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
((14 lines not shown))
+
+ /**
+ * {@inheritDoc}
+ */
+ public function convertBoolToDbValue($item)
+ {
+ if ( ! $this->useBooleanTrueFalseStrings) {
+ return parent::convertBoolToDbValue($item);
+ }
+
+ if (is_array($item)) {
+ foreach ($item as $key => $value) {
+ if (is_bool($value) || is_numeric($value)) {
+ $item[$key] = $value ? 1 : 0;
+ } elseif (is_string($value)) {
+ $item[$key] = (trim(strtolower($value)) === 'false');
@stof
stof added a note

This is weird. You have a real boolean here, while the code uses 1 and 0 just above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
...Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php
@@ -60,12 +61,15 @@ public function testBooleanConversionBoolParamRealPrepares()
public function testBooleanConversionBoolParamEmulatedPrepares()
{
- $this->markTestIncomplete('There is something missing here, on some machines it fails on some it passes.');
+ // $this->markTestIncomplete('There is something missing here, on some machines it fails on some it passes.');
@stof
stof added a note

if the test is not incomplete anymore, this should be removed, not commented

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
...DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php
((20 lines not shown))
{
$platform = $this->createPlatform();
$platform->setUseBooleanTrueFalseStrings(false);
- $this->assertEquals('1', $platform->convertBooleans(true));
- $this->assertEquals('0', $platform->convertBooleans(false));
+ $this->assertEquals('1', $platform->convertBoolToSqlLiteral(true));
@stof
stof added a note

this looks wrong to me

It is exactly like it has ever been.

@stof
stof added a note

note at the time I commented on it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@davividal

Any more thoughts on this?

lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
((12 lines not shown))
}
}
} else {
- if (is_bool($item) || is_numeric($item)) {
- $item = ($item) ? 'true' : 'false';
- }
+ if (is_bool($item) || is_numeric($item)) {
+ $item = ($item) ? 'true' : 'false';
+ } elseif (is_string($item)) {
+ $item = trim(strtolower($item));
+ if ('false' !== $item && 'f' !== $item) {
@deeky666 Collaborator
deeky666 added a note

Is it maybe necessary to take the other valid boolean literals like n, no, off etc (and opposites) into account which are mentioned in the documentation? I'm not sure about this...

I haven't thought about it.

What do you think about a private attribute called $booleansLiterals?

$booleansLiterals = ['true' => ['t', 'true', ...], 'false' => ['f', 'false', ...]];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@deeky666
Collaborator

Btw, is this PR complementary to #527 ?

@davividal

@deeky666 it looks like this PR complements #527 . How should I proceed?

@davividal davividal commented on the diff
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
@@ -716,14 +738,62 @@ public function convertBooleans($item)

If we're not using TrueFalseStrings, convertBooleans('t') won't convert it to neither 1 nor 0.
The same goes for almost every case described in PostgreSQL documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@davividal

@deeky666 @stof any other thoughts on this?

lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
((24 lines not shown))
+ }
+ }
+
+ return $item;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function convertBooleansToDatabaseValue($item)
+ {
+ if ( ! $this->useBooleanTrueFalseStrings) {
+ return parent::convertBooleansToDatabaseValue($item);
+ }
+
+ if (is_array($item)) {
@deeky666 Collaborator

This whole if block is exactly the same as in convertBooleans() except for the values of true and false. Would be nice to avoid code duplication through another private method here IMO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
((49 lines not shown))
}
}
} else {
- if (is_bool($item) || is_numeric($item)) {
- $item = ($item) ? 'true' : 'false';
- }
+ if (is_bool($item) || is_numeric($item)) {
@deeky666 Collaborator

Also this if block is the same as the one from the previous block. Could be extracted, too IMO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
...DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php
((18 lines not shown))
$this->assertEquals('false', $platform->convertBooleans(false));
+ $this->assertEquals('false', $platform->convertBooleans('f'));
+ $this->assertEquals('false', $platform->convertBooleans('false'));
+ $this->assertEquals('false', $platform->convertBooleans('n'));
+ $this->assertEquals('false', $platform->convertBooleans('no'));
+ $this->assertEquals('false', $platform->convertBooleans('off'));
+ $this->assertEquals('false', $platform->convertBooleans('0'));
@deeky666 Collaborator

Could you please use a data provider here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@deeky666
Collaborator

Despite my suggested improvements I am fine with this PR but TBH I don't have a clue about emulated prepared statements in PostgreSQL and I would like to hear someone else's meaning about the validity of this fix. Otherwise it looks reasonable to me.

@deeky666
Collaborator

@beberlei you have made the first step on this issue. Thoughts?

@davividal

@deeky666 I did a refactoring, what do you think?

@deeky666
Collaborator

not quite what I thought. Here is my suggestion (not tested):

/**
 * Converts a single boolean value.
 *
 * First converts the value to its native PHP boolean type
 * and passes it to the given callback function to be reconverted
 * into any custom representation.
 *
 * @param mixed    $value    The value to convert.
 * @param callable $callback The callback function to use for converting the real boolean value.
 *
 * @return mixed
 */
private function convertSingleBooleanValue($value, $callback)
{
    if (null === $value) {
        return $callback(false);
    }

    if (is_bool($value) || is_numeric($value)) {
        return $callback($value ? true : false);
    }

    if (is_string($value) && in_array(trim(strtolower($value)), $this->booleanLiterals['false'])) {
        return $callback(false);
    }

    return $callback(true);
}

/**
 * Converts one or multiple boolean values.
 *
 * First converts the value(s) to their native PHP boolean type
 * and passes them to the given callback function to be reconverted
 * into any custom representation.
 *
 * @param  $item     The value(s) to convert.
 * @param  $callback The callback function to use for converting the real boolean value(s).
 *
 * @return mixed
 */
private function doConvertBooleans($item, $callback)
{
    if (is_array($item)) {
        foreach ($item as $key => $value) {
            $item[$key] = $this->convertSingleBooleanValue($value, $callback);
        }

        return $item;
    }

    return $this->convertSingleBooleanValue($item, $callback);
}

/**
 * {@inheritdoc}
 */
public function convertBooleans($item)
{
    if ( ! $this->useBooleanTrueFalseStrings) {
        return parent::convertBooleans($item);
    }

    return $this->doConvertBooleans(
        $item,
        function ($boolean) {
            return true === $boolean ? 'true' : 'false';
        }
    );
}

/**
 * {@inheritdoc}
 */
public function convertBooleansToDatabaseValue($item)
{
    if ( ! $this->useBooleanTrueFalseStrings) {
        return parent::convertBooleansToDatabaseValue($item);
    }

    return $this->doConvertBooleans(
        $item,
        function ($boolean) {
            return (int) $boolean;
        }
    );
}
@davividal

@deeky666 it works. Your solution is beautiful!

lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
((8 lines not shown))
+ 't',
+ 'true',
+ 'y',
+ 'yes',
+ 'on',
+ '1'
+ ),
+ 'false' => array(
+ 'f',
+ 'false',
+ 'n',
+ 'no',
+ 'off',
+ '0'
+ )
+ );
@deeky666 Collaborator

Wrong indentation. You have 4 spaces to much here from below the array opener. Also I wonder if we even need this map. If you look at your current implementation, we basically only DO and NEED TO check for values evaluating to false, no? Everything else being converted is true anyways. Like if I pass an object or a resource or anything else (stupid but possible) that is not null, false, 0, 'f', 'false', 'n', 'no', 'off' or '0'. What do you think?

@deeky666 Collaborator

Otherwise if we would strictly stick tho this map we would have to throw exceptions for unexpected values which we cannot do IMO because that might break BC.

"Smart" indent, sorry.

I'm not sure. Initially, I was checking only for false values and converting everything else to true. But if I'm using Postgres boolean literals for true, I will use one of these six. If I'm inputing a literal for true different than these, I would expect an error.

This is Postgres behavior btw:

ERROR:  invalid input syntax for type boolean: "my-awesome-true"
LINE 1: SELECT 'my-awesome-true'::BOOLEAN

As for what do I think: I really think that false should be equal to 0, false or null, true otherwise, like C. Diverging from that you get Ruby awesome 0 equals to true. :) [/troll]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@deeky666
Collaborator

@Ocramius can you please have a look at this implementation. I forgot to keep in mind that those methods could be performance sensitive due being used in DBAL type conversion. Do you think we have to undDRY this thing again?

@davividal

@deeky666 @Ocramius @stof can I help with anything to get this merged?

@deeky666
Collaborator

Still waiting for feedback on possible performance implications.
@Ocramius ping

@davividal

Please let me know if I can help with some benchmarking.

@deeky666
Collaborator

@davividal Sure go ahead and do so. Then we don't have to speculate about that :) Basically the conversion via BooleanType is important to know about.

@davividal

Sorry, I wasn't able to do any progress on this.

If anyone could help, I don't know when I will be able to (re-)take this.

@lucasvanlierop lucasvanlierop commented on the diff
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
@@ -704,6 +726,69 @@ protected function _getCreateTableSQL($tableName, array $columns, array $options
}
/**
+ * Converts a single boolean value.
+ *
+ * First converts the value to its native PHP boolean type
+ * and passes it to the given callback function to be reconverted
+ * into any custom representation.
+ *
+ * @param mixed $value The value to convert.
+ * @param callable $callback The callback function to use for converting the real boolean value.
+ *
+ * @return mixed
+ */
+ private function convertSingleBooleanValue($value, $callback)
+ {

To reduce nested complexity this can be rewritten as:

if (null === $value) {
    return $callback(false);
}

if (is_bool($value) || is_numeric($value)) {
    return $callback($value ? true : false);
}

if (!is_string($value)) {
    return $callback(true);
}

/**
 * Better safe than sorry: http://php.net/in_array#106319
 */
if (in_array(trim(strtolower($value)), $this->booleanLiterals['false'], true)) {
    return $callback(false);
} 

if (in_array(trim(strtolower($value)), $this->booleanLiterals['true'], true)) {
    return $callback(true);
}

throw new \UnexpectedValueException("Unrecognized boolean literal '${value}'");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@lucasvanlierop

I've been comparing this PR with the #527 which seems almost finished. And I feel it would be best if that PR is finished and merged soon and the result is merged into this one. It does not do exactly the same but there is overlap and I think it's best if conversion in both directions both work more or less the same way.

@davividal davividal Simplifying code
Kudos to Lucas van Lierop for the refactoring
956d5a7
@Ocramius
Owner

Closing - continuing in #625

@Ocramius Ocramius closed this
@Ocramius Ocramius self-assigned this
@Ocramius Ocramius referenced this pull request in zendframework/zf2
Open

PDO, PostgreSQL and bool #7284

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
16 lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
@@ -2347,8 +2347,10 @@ public function prefersIdentityColumns()
*
* The default conversion in this implementation converts to integers (false => 0, true => 1).
*
- * @param mixed $item
+ * There are two contexts when converting booleans: Literals and Prepared Statements.
+ * This method should handle the literal case
*
+ * @param mixed $item
* @return mixed
*/
public function convertBooleans($item)
@@ -2367,6 +2369,18 @@ public function convertBooleans($item)
}
/**
+ * This method should handle the prepared statements case. When there is no
+ * distinction, it's OK to use the same method.
+ *
+ * @param mixed $item
+ * @return mixed
+ */
+ public function convertBooleansToDatabaseValue($item)
+ {
+ return $this->convertBooleans($item);
+ }
+
+ /**
* Returns the SQL specific for the platform to get the current date.
*
* @return string
View
115 lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
@@ -43,6 +43,28 @@ class PostgreSqlPlatform extends AbstractPlatform
private $useBooleanTrueFalseStrings = true;

If we're not using TrueFalseStrings, convertBooleans('t') won't convert it to neither 1 nor 0.
The same goes for almost every case described in PostgreSQL documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
/**
+ * @var array PostgreSQL booleans literals
+ */
+ private $booleanLiterals = array(
+ 'true' => array(
+ 't',
+ 'true',
+ 'y',
+ 'yes',
+ 'on',
+ '1'
+ ),
+ 'false' => array(
+ 'f',
+ 'false',
+ 'n',
+ 'no',
+ 'off',
+ '0'
+ )
+ );
+
+ /**
* PostgreSQL has different behavior with some drivers
* with regard to how booleans have to be handled.
*
@@ -704,6 +726,69 @@ protected function _getCreateTableSQL($tableName, array $columns, array $options
}
/**
+ * Converts a single boolean value.
+ *
+ * First converts the value to its native PHP boolean type
+ * and passes it to the given callback function to be reconverted
+ * into any custom representation.
+ *
+ * @param mixed $value The value to convert.
+ * @param callable $callback The callback function to use for converting the real boolean value.
+ *
+ * @return mixed
+ */
+ private function convertSingleBooleanValue($value, $callback)
+ {

To reduce nested complexity this can be rewritten as:

if (null === $value) {
    return $callback(false);
}

if (is_bool($value) || is_numeric($value)) {
    return $callback($value ? true : false);
}

if (!is_string($value)) {
    return $callback(true);
}

/**
 * Better safe than sorry: http://php.net/in_array#106319
 */
if (in_array(trim(strtolower($value)), $this->booleanLiterals['false'], true)) {
    return $callback(false);
} 

if (in_array(trim(strtolower($value)), $this->booleanLiterals['true'], true)) {
    return $callback(true);
}

throw new \UnexpectedValueException("Unrecognized boolean literal '${value}'");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ if (null === $value) {
+ return $callback(false);
+ }
+
+ if (is_bool($value) || is_numeric($value)) {
+ return $callback($value ? true : false);
+ }
+
+ if ( ! is_string($value)) {
+ return $callback(true);
+ }
+
+ /**
+ * Better safe than sorry: http://php.net/in_array#106319
+ */
+ if (in_array(trim(strtolower($value)), $this->booleanLiterals['false'], true)) {
+ return $callback(false);
+ } elseif (in_array(trim(strtolower($value)), $this->booleanLiterals['true'], true)) {
+ return $callback(true);
+ } else {
+ throw new \UnexpectedValueException("Unrecognized boolean literal '${value}'");
+ }
+ }
+
+ /**
+ * Converts one or multiple boolean values.
+ *
+ * First converts the value(s) to their native PHP boolean type
+ * and passes them to the given callback function to be reconverted
+ * into any custom representation.
+ *
+ * @param $item The value(s) to convert.
+ * @param $callback The callback function to use for converting the real boolean value(s).
+ *
+ * @return mixed
+ */
+ private function doConvertBooleans($item, $callback)
+ {
+ if (is_array($item)) {
+ foreach ($item as $key => $value) {
+ $item[$key] = $this->convertSingleBooleanValue($value, $callback);
+ }
+
+ return $item;
+ }
+
+ return $this->convertSingleBooleanValue($item, $callback);
+ }
+
+ /**
* {@inheritDoc}
*
* Postgres wants boolean values converted to the strings 'true'/'false'.
@@ -714,19 +799,29 @@ public function convertBooleans($item)
return parent::convertBooleans($item);
}
- if (is_array($item)) {
- foreach ($item as $key => $value) {
- if (is_bool($value) || is_numeric($item)) {
- $item[$key] = ($value) ? 'true' : 'false';
- }
+ return $this->doConvertBooleans(
+ $item,
+ function ($boolean) {
+ return true === $boolean ? 'true' : 'false';
}
- } else {
- if (is_bool($item) || is_numeric($item)) {
- $item = ($item) ? 'true' : 'false';
- }
+ );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function convertBooleansToDatabaseValue($item)
+ {
+ if ( ! $this->useBooleanTrueFalseStrings) {
+ return parent::convertBooleansToDatabaseValue($item);
}
- return $item;
+ return $this->doConvertBooleans(
+ $item,
+ function ($boolean) {
+ return (int) $boolean;
+ }
+ );
}
/**
View
2  lib/Doctrine/DBAL/Types/BooleanType.php
@@ -41,7 +41,7 @@ public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $pla
*/
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
- return $platform->convertBooleans($value);
+ return $platform->convertBooleansToDatabaseValue($value);
}
/**
View
10 tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php
@@ -33,6 +33,7 @@ protected function tearDown()
{
if ($this->running) {
$this->_conn->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
+ $this->_conn->getWrappedConnection()->setAttribute(PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT, false);
}
}
@@ -60,12 +61,13 @@ public function testBooleanConversionBoolParamRealPrepares()
public function testBooleanConversionBoolParamEmulatedPrepares()
{
- $this->markTestIncomplete('There is something missing here, on some machines it fails on some it passes.');
-
$this->_conn->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
+ $this->_conn->getWrappedConnection()->setAttribute(PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT, true);
+
+ $platform = $this->_conn->getDatabasePlatform();
$stmt = $this->_conn->prepare('INSERT INTO dbal630 (bool_col) VALUES(?)');
- $stmt->bindValue(1, 'false', PDO::PARAM_BOOL);
+ $stmt->bindValue(1, $platform->convertBooleansToDatabaseValue('false'), PDO::PARAM_BOOL);
$stmt->execute();
$id = $this->_conn->lastInsertId('dbal630_id_seq');
@@ -74,6 +76,6 @@ public function testBooleanConversionBoolParamEmulatedPrepares()
$row = $this->_conn->fetchAssoc('SELECT bool_col FROM dbal630 WHERE id = ?', array($id));
- $this->assertTrue($row['bool_col']);
+ $this->assertFalse($row['bool_col']);
}
}
View
97 tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php
@@ -291,25 +291,60 @@ protected function getQuotedColumnInForeignKeySQL()
/**
* @group DBAL-457
+ * @dataProvider pgStringBooleanProvider
*/
- public function testConvertBooleanAsStrings()
+ public function testConvertBooleanAsLiteralStrings($expected, $input)
{
$platform = $this->createPlatform();
- $this->assertEquals('true', $platform->convertBooleans(true));
- $this->assertEquals('false', $platform->convertBooleans(false));
+ $this->assertEquals($expected, $platform->convertBooleans($input));
}
/**
* @group DBAL-457
*/
- public function testConvertBooleanAsIntegers()
+ public function testConvertBooleanAsLiteralIntegers()
{
$platform = $this->createPlatform();
$platform->setUseBooleanTrueFalseStrings(false);
- $this->assertEquals('1', $platform->convertBooleans(true));
- $this->assertEquals('0', $platform->convertBooleans(false));
+ $this->assertEquals(1, $platform->convertBooleans(true));
+ $this->assertEquals(1, $platform->convertBooleans('1'));
+
+ $this->assertEquals(0, $platform->convertBooleans(false));
+ $this->assertEquals(0, $platform->convertBooleans('0'));
+ }
+
+ /**
+ * @group DBAL-630
+ * @dataProvider pgStringBooleanDatabaseValueProvider
+ */
+ public function testConvertBooleanAsDatabaseValueStrings($expected, $input)
+ {
+ $platform = $this->createPlatform();
+
+ $this->assertEquals($expected, $platform->convertBooleansToDatabaseValue($input));
+ }
+
+ /**
+ * @group DBAL-630
+ */
+ public function testConvertBooleanAsDatabaseValueIntegers()
+ {
+ $platform = $this->createPlatform();
+ $platform->setUseBooleanTrueFalseStrings(false);
+
+ $this->assertEquals(1, $platform->convertBooleansToDatabaseValue(true));
+ $this->assertEquals(0, $platform->convertBooleansToDatabaseValue(false));
+ }
+
+ /**
+ * @expectedException UnexpectedValueException
+ * @expectedExceptionMessage Unrecognized boolean literal 'my-bool'
+ */
+ public function testThrowsExceptionWithInvalidBooleanLiteral()
+ {
+ $platform = $this->createPlatform()->convertBooleansToDatabaseValue("my-bool");
}
public function testGetCreateSchemaSQL()
@@ -521,4 +556,54 @@ protected function getQuotedAlterTableRenameIndexSQL()
'ALTER INDEX "foo" RENAME TO "bar"',
);
}
+
+ /**
+ * PostgreSQL boolean strings provider
+ * @return array
+ */
+ public function pgStringBooleanProvider()
+ {
+ return array(
+ array('true', true),
+ array('true', 't'),
+ array('true', 'true'),
+ array('true', 'y'),
+ array('true', 'yes'),
+ array('true', 'on'),
+ array('true', '1'),
+
+ array('false', false),
+ array('false', 'f'),
+ array('false', 'false'),
+ array('false', 'n'),
+ array('false', 'no'),
+ array('false', 'off'),
+ array('false', '0'),
+ );
+ }
+
+ /**
+ * PostgreSQL boolean strings as database values provider
+ * @return array
+ */
+ public function pgStringBooleanDatabaseValueProvider()
+ {
+ return array(
+ array(1, true),
+ array(1, 't'),
+ array(1, 'true'),
+ array(1, 'y'),
+ array(1, 'yes'),
+ array(1, 'on'),
+ array(1, '1'),
+
+ array(0, false),
+ array(0, 'f'),
+ array(0, 'false'),
+ array(0, 'n'),
+ array(0, 'no'),
+ array(0, 'off'),
+ array(0, '0'),
+ );
+ }
}
Something went wrong with that request. Please try again.