Are you sure that idAspNetUser Asecor is of the same type as Id on User?
This seems to indicate that one is an integer (and I assume the other is a string)
character varying = integer
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello everyone, I am getting this error after doing this query, I migrated from Laravel 5.6 to 5.7 and this query started to fail
query
$asesores = Asesor::with(['usuario' => function ($q) {
$q->orderBy('NombreCompleto')
->select('NombreCompleto AS id','NombreCompleto AS text', 'Id');
}])
->get()
->pluck('usuario')
->toJson();
error, doing tests I saw that it is in the method with::('usuario') that I get the error
Illuminate \ Database \ QueryException (42883)
SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: character varying = integer LINE 1: ...dbo"."AspNetUsers" where "dbo"."AspNetUsers"."Id" in (0, 350... ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. (SQL: select * from "dbo"."AspNetUsers" where "dbo"."AspNetUsers"."Id" in (0, 3502, 9223372036854775807, 658209000, 6, 6, 7, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0))
Asesor model
protected $table = 'SETCON.Asesor';
protected $primaryKey = 'idAspNetUser';
protected $keyType = 'string';
public function usuario()
{
return $this->hasOne('App\User', 'Id');
}
User model
protected $primaryKey = 'Id';
protected $keyType = 'string';
protected $table = 'dbo.AspNetUsers';
public function asesor()
{
return $this->belongsTo('App\modelos\Asesor', 'Id');
}
I still don't understand why I have this error, thanks in advance
Please or to participate in this conversation.