我正在尝试使用该SQLite.swift
库快速加入一些表格,但遇到了一些问题。下面的代码显示了这个问题:
我首先加入表格:
let ext_tasks = tasks.join(tasktypes, on: tasktypes[tty_id] == tasks[task_type])
.join(preUsers, on: preUsers[Worker_ID] == task_ownerID)
.order(task_dueDate)
.filter(task_ownerID == iUserID)
在这一点上,我已经加入了表格和来自的所有字段tasks
,task types
并且preUsers
都正确存在。
在我运行第二个 join 语句之后:
let ext_equipment = equipment.join(equipment_type, on: equipment_type[eqt_id] == equipment[equ_type])
.join(facilities, on: facilities[fac_id] == equipment[equ_facid])
.join(eqowners, on: eqowners[Worker_ID] == equipment[equ_owner])
.order(equ_make)
.filter(equ_status >= 0)
同样,在运行此语句后,我可以访问、和表中的所有字段equipment
,直到这里一切都按预期工作......equipment_type
facilities
eqowners
但是,然后我尝试使用以下方法加入上述两个结果:
let comp_tasks = ext_tasks.join(ext_equipment, on: ext_equipment[equ_id] == ext_tasks[task_eqID])
.order(task_dueDate)
这是我遇到问题的地方,似乎来自ext_tasks
查询的表在那里,但只有equipment
来自查询的表ext_equipment
可用。
此外,当我尝试访问该"facilities"."facility_name"
字段时,我收到以下消息,指出该字段不存在:
致命错误:列中没有这样的列 '"Facility"."Facility_Name"':
[“设备”。“设备类型_ID”,“设备”。“设备_ID”,“设备”。“设备_所有者_ID”,“设备”。“设施_ID”,“设备”。“状态”,“预用户”。“客户ID”,“ PreUsers”。“Date_LastLogin”,“PreUsers”。“First_Name”,“TaskTypes”。“TaskType_ID”,“TaskTypes”。“Type”,“Tasks”。“Equipment_ID”,“Tasks”。“Owner_ID”,“Tasks” ."Priority", "Tasks"."Time_Complete", "Tasks"."Time_Start"]:
(我删除了其中的一些列以缩短答案,总共显示了 53 个字段)但是您可以看到只显示第一个连接中的表 + 设备表,第二个查询(equipment_type, facilities and eqowners
)中的连接无处被看见
如果有人能让我知道为什么会这样,我将不胜感激,这已经让我的大脑死了好几个小时,我就是想不通......
提前致谢!