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

[5.4.21]bug fix. when use other connection in model, set the correct connecti… #19049

Closed
wants to merge 1 commit into from

Conversation

devbian
Copy link

@devbian devbian commented May 4, 2017

when use different connection in model, like protected $connection='oracle', get data is ok, but if update or save, will got exception. because of the connection info lost.
this pull request will fix the bug.

this bug appear on 5.4.21.

@devbian devbian changed the title bug fix. when use other connection in model, set the correct connecti… [5.4.21]bug fix. when use other connection in model, set the correct connecti… May 4, 2017
@taylorotwell
Copy link
Member

@themsaid can you research this?

@arcanedev-maroc
Copy link
Contributor

arcanedev-maroc commented May 4, 2017

I don't think oracle db driver is supported by laravel.

Are you using a third package for this db connection ?

@ConnorVG
Copy link
Contributor

ConnorVG commented May 4, 2017

@arcanedev-maroc that's irrelevant. We'd write tests with what we support.

@themsaid
Copy link
Member

themsaid commented May 4, 2017

As I mentioned in the issue #19030, I can't replicate the reported behaviour, saving and retrieving on a non-default connection seems to work fine.

class User extends Authenticatable
{
    use Notifiable;

    protected $connection = 'mysql2';

}
$user = \App\User::find(1);

    $user->name = 'zzzz';

    $user->save();

This code fetches the record for the mysql2 connection and updates the name on mysql2 connection.

@themsaid
Copy link
Member

themsaid commented May 4, 2017

Looks like the reports are all related to this package (https://github.com/yajra/laravel-oci8), please check with the maintainers.

@fernandobandeira
Copy link
Contributor

@themsaid I think actually what broke this was this change:

      public function fromQuery($query, $bindings = [])
      {
 -        $instance = $this->model->newInstance();
 -
          return $this->hydrate(
 -            $instance->getConnection()->select($query, $bindings)
 +            $this->query->getConnection()->select($query, $bindings)
          );
      }

from the pr #18775

All the other changes seems to keep the same behavior however this one seems to change it a little bit...

@themsaid
Copy link
Member

themsaid commented May 4, 2017

I really need to be able to replicate :) I can't seem to find a difference in behaviour, if someone can point me to a case that was broken by the commit that I can replicate I can look further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants