with 关联,主表无法指定字段
easyswoole框架版本号、orm组件版本号 [Version]
easyswoole 3.4.5 , orm 1.4 $res = ClientDataAccountModel::create() ->alias('dataAccount') ->field('dataAccount.id') ->with('account_users') ->all(['id' => $account_id]); //关联模型 return $this->belongsToMany(OrganizationUserModel::class, "sk_client_data_account_users",'data_account_id','data_database_uid',function($query){ $query->fields("id,organization_id,account,status,name,phone,username"); }); }
报错如下
Unknown column 'data_account_id' in 'field list' [SELECT dataAccount.id, data_account_id FROM sk_client_data_account AS dataAccount WHERE id = 1
经过排查是 abstractModel 960 行 if (!in_array($pk, $this->fields) && $this->supplyPk == true){ $this->fields[] = $pk; } 这里的问题
排查情况和最小复现脚本 [Tests and Recurrence]
Source: easy-swoole/orm