Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disableJsonSupport on multiple database connections #16907

Open
shranet opened this issue Nov 23, 2018 · 1 comment
Open

disableJsonSupport on multiple database connections #16907

shranet opened this issue Nov 23, 2018 · 1 comment
Labels
status:to be verified Needs to be reproduced and validated. type:bug Bug

Comments

@shranet
Copy link

shranet commented Nov 23, 2018

I have two configurations for database connections! In all configurations host, dbname, username and password are same value!

//Yii::$app->db
return [
    'class' => 'yii\db\Connection',
    'dsn' => 'pgsql:host=***;dbname=***',
    'username' => '***',
    'password' => '***',
    'charset' => 'utf8',
    'schemaMap' => [
        'pgsql' => [
            'class' => 'yii\db\pgsql\Schema',
            'defaultSchema' => 'public' //specify your schema here, public is the default schema
        ]
    ], // PostgreSQL
];

and

//Yii::$app->db2
return [
    'class' => 'yii\db\Connection',
    'dsn' => 'pgsql:host=***;dbname=***',
    'username' => '***',
    'password' => '***',
    'charset' => 'utf8',
    'schemaMap' => [
        'pgsql' => [
            'class' => 'yii\db\pgsql\Schema',
            'defaultSchema' => 'public', //specify your schema here, public is the default schema
            'columnSchemaClass' => [
                'class' => yii\db\pgsql\ColumnSchema::class,
                'disableJsonSupport' => true,
                'disableArraySupport' => true,
                'deserializeArrayColumnToArrayExpression' => false,
            ],
        ]
    ], // PostgreSQL
];

In second configuration I disable disableJsonSupport and disableArraySupport!
And I used like this:

$result1 = CountriesModel::find()->where(["id" => 1])->one();
$result2 = CountriesModel::find()->where(["id" => 1])->one(Yii::$app->db2);

print_variable($result1->attributes);
print_variable($result2->attributes);

Lonely result:

Array
(
    [id] => 1
    [name] => Array
        (
            [en] => Aruba
            [ru] => Aruba
            [uz] => Aruba
        )

    [long_name] => Array
        (
            [en] => Aruba
            [ru] => Aruba
            [uz] => Aruba
        )

    [slug] => Array
        (
            [en] => aruba
            [ru] => aruba
            [uz] => 
        )

    [iso2] => AW
    [iso3] => ABW
    [status] => 1
    [created_at] => 2018-11-07 10:47:00
    [updated_at] => 2018-11-19 12:27:26
)

and

Array
(
    [id] => 1
    [name] => Array
        (
            [en] => Aruba
            [ru] => Aruba
            [uz] => Aruba
        )

    [long_name] => Array
        (
            [en] => Aruba
            [ru] => Aruba
            [uz] => Aruba
        )

    [slug] => Array
        (
            [en] => aruba
            [ru] => aruba
            [uz] => 
        )

    [iso2] => AW
    [iso3] => ABW
    [status] => 1
    [created_at] => 2018-11-07 10:47:00
    [updated_at] => 2018-11-19 12:27:26
)
Q A
Yii version 2.0.15.1
PHP version 7.2.10
Operating system Ubuntu 18.04.1 LTS

Sorry my english! I use Google uncle :)

@shranet shranet changed the title disableJsonSupport on miltiple database connection disableJsonSupport on miltiple database connections Nov 23, 2018
@shranet shranet changed the title disableJsonSupport on miltiple database connections disableJsonSupport on multiple database connections Nov 23, 2018
@samdark samdark added type:bug Bug status:to be verified Needs to be reproduced and validated. labels Nov 23, 2018
@samdark
Copy link
Member

samdark commented Nov 23, 2018

@SilverFire looks like it's connected to the feature you've introduced. Mind taking a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:to be verified Needs to be reproduced and validated. type:bug Bug
Projects
None yet
Development

No branches or pull requests

2 participants