Rename table references

This commit is contained in:
jude 2024-02-14 19:44:53 +00:00
parent 96012ce43c
commit 2f6d035efe
4 changed files with 11 additions and 10 deletions

View File

@ -22,10 +22,11 @@ pub async fn macro_name_autocomplete(ctx: Context<'_>, partial: &str) -> Vec<Str
sqlx::query!( sqlx::query!(
" "
SELECT name SELECT name
FROM macro FROM command_macro
WHERE WHERE
guild_id = (SELECT id FROM guilds WHERE guild = ?) guild_id = (SELECT id FROM guilds WHERE guild = ?)
AND name LIKE CONCAT(?, '%')", AND name LIKE CONCAT(?, '%')
",
ctx.guild_id().unwrap().get(), ctx.guild_id().unwrap().get(),
partial, partial,
) )

View File

@ -18,7 +18,7 @@ pub async fn delete_macro(
match sqlx::query!( match sqlx::query!(
" "
SELECT m.id SELECT m.id
FROM macro m FROM command_macro m
INNER JOIN guilds INNER JOIN guilds
ON guilds.guild = m.guild_id ON guilds.guild = m.guild_id
WHERE guild = ? WHERE guild = ?
@ -31,7 +31,7 @@ pub async fn delete_macro(
.await .await
{ {
Ok(row) => { Ok(row) => {
sqlx::query!("DELETE FROM macro WHERE id = ?", row.id) sqlx::query!("DELETE FROM command_macro WHERE id = ?", row.id)
.execute(&ctx.data().database) .execute(&ctx.data().database)
.await .await
.unwrap(); .unwrap();

View File

@ -34,7 +34,7 @@ pub async fn record_macro(
let row = sqlx::query!( let row = sqlx::query!(
" "
SELECT 1 as _e SELECT 1 as _e
FROM macro FROM command_macro
WHERE guild_id = (SELECT id FROM guilds WHERE guild = ?) WHERE guild_id = (SELECT id FROM guilds WHERE guild = ?)
AND name = ? AND name = ?
", ",
@ -131,7 +131,7 @@ pub async fn finish_macro(ctx: Context<'_>) -> Result<(), Error> {
let json = serde_json::to_string(&command_macro.commands).unwrap(); let json = serde_json::to_string(&command_macro.commands).unwrap();
sqlx::query!( sqlx::query!(
"INSERT INTO macro (guild_id, name, description, commands) VALUES ((SELECT id FROM guilds WHERE guild = ?), ?, ?, ?)", "INSERT INTO command_macro (guild_id, name, description, commands) VALUES ((SELECT id FROM guilds WHERE guild = ?), ?, ?, ?)",
command_macro.guild_id.get(), command_macro.guild_id.get(),
command_macro.name, command_macro.name,
command_macro.description, command_macro.description,

View File

@ -55,7 +55,7 @@ pub async fn guild_command_macro(ctx: &Context<'_>, name: &str) -> Option<Comman
let row = sqlx::query!( let row = sqlx::query!(
" "
SELECT m.id, m.name, m.description, m.commands SELECT m.id, m.name, m.description, m.commands
FROM macro m FROM command_macro m
INNER JOIN guilds g INNER JOIN guilds g
ON g.id = m.guild_id ON g.id = m.guild_id
WHERE guild = ? WHERE guild = ?