Skip to content

Field Not quoted for fetching relation data with joinWith #11088

@avinashz

Description

@avinashz

I am having three tables.

  • User
  • Regions
  • Country

Relations are built like below:

  • User hasMany Regions
  • Regions hasOne Country

I have relation build for fetching regions of user in User Model and one more relation is there in Region Model to get related country.

If I do eager loading like this the my Primary key of region is not quoted. Let me show you waht works and what not.

Works:

$userModel->getRegions()->with('country')->all();

This works may be becuase we will have separate query. Correct?

Field Not Quoted:

$userModel->getRegions()->joinWith('country')->all();

In MySQL it will work but in case of PG, that is required to have the field quoted specially when you have camel casing. Have a look at generated query.

SELECT "region".* FROM "region" LEFT JOIN "country" ON "region"."CountryID" = "country"."CountryID" WHERE "region".UserID=8

You can see that last field which is primary key of my User model is not quoted.

PHP: 5.5.12
Yii2: 2.0.7

Am i missing something here or its bug over there?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions