LEFT OUTER JOIN rather than INNER JOIN
parent
f977eb63da
commit
adcd6f395c
|
@ -1,9 +1,14 @@
|
|||
module Api
|
||||
class ToolsController < Api::AbstractController
|
||||
INDEX_QUERY = 'SELECT "tools".*, points.id as tool_slot_id FROM "tools" ' \
|
||||
'INNER JOIN "points" ON "points"."tool_id" = "tools"."id" ' \
|
||||
'AND "points"."pointer_type" IN (\'ToolSlot\') WHERE "tools"'\
|
||||
'."device_id" = %s;'
|
||||
INDEX_QUERY = 'SELECT
|
||||
"tools".*,
|
||||
points.id as tool_slot_id
|
||||
FROM
|
||||
"tools"
|
||||
LEFT OUTER JOIN
|
||||
"points" ON "points"."tool_id" = "tools"."id"
|
||||
WHERE
|
||||
"tools"."device_id" = %s;'
|
||||
|
||||
def index
|
||||
render json: tools
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
module Tools
|
||||
class Create < Mutations::Command
|
||||
required do
|
||||
string :name
|
||||
model :device, class: Device
|
||||
string :name
|
||||
model :device, class: Device
|
||||
end
|
||||
|
||||
def execute
|
||||
|
|
|
@ -94,7 +94,18 @@ describe Api::SavedGardensController do
|
|||
# saved_garden = FactoryBot.create(:saved_garden, device: user.device)
|
||||
# FactoryBot.create_list(:plant_template, 3, device: user.device,
|
||||
# saved_garden: saved_garden)
|
||||
# puts "Create sequence using a plant"
|
||||
# FakeSequence.create(device: user.device,
|
||||
# body: [{ kind: "move_absolute",
|
||||
# args: {
|
||||
# location: {
|
||||
# kind: "point",
|
||||
# args: { pointer_type: "Plant", pointer_id: plant.id }
|
||||
# },
|
||||
# speed: 100,
|
||||
# offset: { kind: "", args: { } }
|
||||
# }
|
||||
# }])
|
||||
|
||||
# old_plant_count = user.device.plants.count
|
||||
# patch :apply, params: {id: saved_garden.id }
|
||||
# expect(response.status).to be(200)
|
||||
|
|
Loading…
Reference in New Issue