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

morphOne $model (mysql) -> relation (mongo) #2875

Open
busaku opened this issue Apr 16, 2024 · 1 comment
Open

morphOne $model (mysql) -> relation (mongo) #2875

busaku opened this issue Apr 16, 2024 · 1 comment
Labels
relations Relations between documents

Comments

@busaku
Copy link

busaku commented Apr 16, 2024

  • Laravel-mongodb Version: 4.2.0
  • PHP Version: 8.3.4
  • Database Driver & Version: php8.3-mongodb latest

Description:

I have a model with a mysql collection e.g.
$product. with a meta-field relation (morphOne) to a MetaData model (mongoDB).
$this->meta()->toMql() will show a query like
{ $and: [{"meta.metable_id": "<prodId>", "meta.metable_type": "<prodEntity>"}]}
But: I dont know where the meta. prefix comes from.
If you just create a $this->meta()->make() Model. The values got prefilled correcty (just metable_id and metable_type, without meta. prefix)

Steps to reproduce

  1. Create a morhOne relationShip inside a model who uses a mysql-db:
public function meta(): MorphOne
    {
        return $this->morphOne(MetaData::class, 'metable');
    }

add it to a MetaData model who use mongoDB

    public function metable(): MorphTo
    {
        return $this->morphTo(__FUNCTION__, 'metable_type', 'metable_id');
    }
  1. Run $model->relation()->toMql();
  2. -> see the result with the wrong relation-fields prefixed with meta.

(It did not happend if the $model is an Mongo-Model too!)

Expected behaviour

Use the correct field names (not prefixed with meta.)

Actual behaviour

It put the prefix meta. in front of "metable" field names

@GromNaN
Copy link
Member

GromNaN commented Sep 4, 2024

May be related to PHPORM-226 #3093

@GromNaN GromNaN added the relations Relations between documents label Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relations Relations between documents
Projects
None yet
Development

No branches or pull requests

2 participants