Skip to content

Commit

Permalink
♻️ IGNORE -> REPLACE
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsutakein committed Jan 2, 2024
1 parent 36c0872 commit ba5caa7
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,13 @@ SELECT participants.status, profiles.* FROM participants
INNER JOIN profiles ON participants.user_id = profiles.id
WHERE participants.schedule_id IN :schedule_id;

upsert {
UPDATE participants SET
`status` = :status
WHERE schedule_id = :schedule_id AND user_id = :user_id;

INSERT OR IGNORE INTO participants (
`schedule_id`,
`user_id`,
`status`
) VALUES (
:schedule_id,
:user_id,
:status
);
}
upsert:
INSERT OR REPLACE INTO participants (
`schedule_id`,
`user_id`,
`status`
) VALUES (
:schedule_id,
:user_id,
:status
);
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,19 @@ SELECT *
FROM places
WHERE id = ?;

upsert {
UPDATE places SET
`name` = :name,
`url` = :url,
`map_url` = :map_url,
`image_url` = :image_url,
`description` = :description
WHERE `id` = :id;

INSERT OR IGNORE INTO places (
`id`,
`name`,
`url`,
`map_url`,
`image_url`,
`description`
) VALUES (
:id,
:name,
:url,
:map_url,
:image_url,
:description
);
}
upsert:
INSERT OR REPLACE INTO places (
`id`,
`name`,
`url`,
`map_url`,
`image_url`,
`description`
) VALUES (
:id,
:name,
:url,
:map_url,
:image_url,
:description
);
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,17 @@ SELECT *
FROM profiles
WHERE id IN ?;

upsert {
UPDATE profiles SET
`username` = :username,
`display_name` = :display_name,
`avatar_url` = :avatar_url,
`website` = :website
WHERE `id` = :id;

INSERT OR IGNORE INTO profiles (
`id`,
`username`,
`display_name`,
`avatar_url`,
`website`
) VALUES (
:id,
:username,
:display_name,
:avatar_url,
:website
);
}
upsert:
INSERT OR REPLACE INTO profiles (
`id`,
`username`,
`display_name`,
`avatar_url`,
`website`
) VALUES (
:id,
:username,
:display_name,
:avatar_url,
:website
);
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,19 @@ INNER JOIN places venue ON schedules.venue_id = venue.id
INNER JOIN places meet ON schedules.meet_id = meet.id
WHERE schedules.id = :schedule_id;

upsert {
UPDATE schedules SET
`scheduled_at` = :scheduled_at,
`venue_id` = :venue_id,
`meet_id` = :meet_id,
`description` = :description,
`met_at` = :met_at
WHERE `id` = :id;

INSERT OR IGNORE INTO schedules (
`id`,
`scheduled_at`,
`venue_id`,
`meet_id`,
`description`,
`met_at`
) VALUES (
:id,
:scheduled_at,
:venue_id,
:meet_id,
:description,
:met_at
);
}
upsert:
INSERT OR REPLACE INTO schedules (
`id`,
`scheduled_at`,
`venue_id`,
`meet_id`,
`description`,
`met_at`
) VALUES (
:id,
:scheduled_at,
:venue_id,
:meet_id,
:description,
:met_at
);

0 comments on commit ba5caa7

Please sign in to comment.