laravel - Laravel Postgres SQLSTATE [42601]:语法错误:7 错误:“”“”或附近的零长度分隔标识符
问题描述
我正在尝试使用 laravel 播种数据,但尽管尝试将所有内容替换""
为''
我的代码
foreach ($groupPermissionsStructure as $groupName => $permissionStructure) {
$group = collect($groups->where('alias', $groupName)->first());
if ($group->isNotEmpty()) {
$group = Group::firstOrCreate([
'name' => $group['name'],
'alias' => strtolower($group['alias']),
'description' => $group['description'],
'organization_id' => 1,
'status' => 1,
]);
$names = explode(" ", $group['name']);
$domain = str_replace([" ", "-", "_"], "", $groupName);
User::firstOrCreate([
'first_name' => $names[0],
'last_name' => isset($names[1]) ? $names[1] : $names[0],
'email' => $domain . '@test.com',
'email_verified_at' => Carbon::now(),
'status' => config('constants.status.active'),
'group_id' => $group->id,
'password' => Hash::make($domain)
]);
}
我的错误
SQLSTATE[42601]: Syntax error: 7 ERROR: zero-length delimited identifier at or near """"
LINE 1: select * from ""."groups" where ("name" = $1 and "alias" = $...
^ (SQL: select * from ""."groups" where ("name" = Super Administrator and "alias" = super_administrator and "description" = Overall system super administrator and "organization_id" = 1 and "status" = 1) and ""."groups"."deleted_at" is null limit 1)
解决方案
推荐阅读
- reactjs - 从 redux 打开带有 props 状态的弹出窗口
- azure - 在运行时在数据工厂管道中设置链接服务参数
- amazon-web-services - AWS DynamoDB | DynamoDB 可以设置服务器端时间戳吗?
- node.js - client.connect 上的“未捕获的 TypeError:this._socket.write 不是函数”
- excel - 如何将光标聚焦到带有预插入斜杠(_ _/_ _/_ _ _ _)的文本框的起始位置,用于 VBA 中的日期字段
- php - 在每次页面刷新时获取不同的随机帖子
- javascript - 如何使用 php/javascript 仅显示 url 中的特定参数?
- amazon-web-services - 如何在 aws-sam template.yaml 文件中添加插件
- omnet++ - 如何在 Veins 中发送二进制数据
- android - 如何将字符串日期解析为其他时区的其他日期