Skip to content

Commit

Permalink
update: comments related to mysql syntax for db flush
Browse files Browse the repository at this point in the history
  • Loading branch information
Roardom committed Jan 13, 2025
1 parent 2920020 commit 636f076
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/scheduler/history_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ impl Flushable<HistoryUpdate> for super::Batch<Index, HistoryUpdate> {
"#,
);

// Mysql 8.0.20 deprecates use of VALUES() so will have to update it eventually to use aliases instead
query_builder
// .push_values(history_updates., |mut bind, (index, history_update)| {
// Trailing space required before the push values function
// Leading space required after the push values function
.push_values(self.iter(), |mut bind, (index, history_update)| {
bind.push_bind(index.user_id)
.push_bind(index.torrent_id)
Expand All @@ -97,6 +97,8 @@ impl Flushable<HistoryUpdate> for super::Batch<Index, HistoryUpdate> {
.push_bind(history_update.updated_at)
.push_bind(history_update.completed_at);
})
// Mysql 8.0.20 deprecates use of VALUES() so will have to update it eventually to use aliases instead
// However, Mariadb doesn't yet support aliases
.push(
r#"
ON DUPLICATE KEY UPDATE
Expand Down
4 changes: 4 additions & 0 deletions src/scheduler/peer_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ impl Flushable<PeerUpdate> for super::Batch<Index, PeerUpdate> {
);

query_builder
// Trailing space required before the push values function
// Leading space required after the push values function
.push_values(self.iter(), |mut bind, (index, peer_update)| {
bind.push_bind(index.peer_id.to_vec())
.push_bind(match peer_update.ip {
Expand All @@ -99,6 +101,8 @@ impl Flushable<PeerUpdate> for super::Batch<Index, PeerUpdate> {
.push_bind(index.user_id)
.push_bind(peer_update.connectable);
})
// Mysql 8.0.20 deprecates use of VALUES() so will have to update it eventually to use aliases instead
// However, Mariadb doesn't yet support aliases
.push(
r#"
ON DUPLICATE KEY UPDATE
Expand Down
6 changes: 4 additions & 2 deletions src/scheduler/torrent_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ impl Flushable<TorrentUpdate> for super::Batch<Index, TorrentUpdate> {

let now = Utc::now();

// Trailing space required before the push values function
// Leading space required after the push values function
let mut query_builder: QueryBuilder<MySql> = QueryBuilder::new(
r#"
INSERT INTO
Expand All @@ -65,6 +63,8 @@ impl Flushable<TorrentUpdate> for super::Batch<Index, TorrentUpdate> {
);

query_builder
// Trailing space required before the push values function
// Leading space required after the push values function
.push_values(self.iter(), |mut bind, (index, torrent_update)| {
bind.push_bind(index.torrent_id)
.push_bind("")
Expand All @@ -82,6 +82,8 @@ impl Flushable<TorrentUpdate> for super::Batch<Index, TorrentUpdate> {
.push_bind(torrent_update.balance_delta)
.push_bind(0);
})
// Mysql 8.0.20 deprecates use of VALUES() so will have to update it eventually to use aliases instead
// However, Mariadb doesn't yet support aliases
.push(
r#"
ON DUPLICATE KEY UPDATE
Expand Down
4 changes: 4 additions & 0 deletions src/scheduler/unregistered_info_hash_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ impl Flushable<UnregisteredInfoHashUpdate> for super::Batch<Index, UnregisteredI
);

query_builder
// Trailing space required before the push values function
// Leading space required after the push values function
.push_values(
self.iter(),
|mut bind, (index, unregistered_info_hash_update)| {
Expand All @@ -56,6 +58,8 @@ impl Flushable<UnregisteredInfoHashUpdate> for super::Batch<Index, UnregisteredI
.push_bind(unregistered_info_hash_update.updated_at);
},
)
// Mysql 8.0.20 deprecates use of VALUES() so will have to update it eventually to use aliases instead
// However, Mariadb doesn't yet support aliases
.push(
r#"
ON DUPLICATE KEY UPDATE
Expand Down
6 changes: 4 additions & 2 deletions src/scheduler/user_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ impl Flushable<UserUpdate> for super::Batch<Index, UserUpdate> {
return Ok(0);
}

// Trailing space required before the push values function
// Leading space required after the push values function
let mut query_builder: QueryBuilder<MySql> = QueryBuilder::new(
r#"
INSERT INTO
Expand All @@ -53,6 +51,8 @@ impl Flushable<UserUpdate> for super::Batch<Index, UserUpdate> {
);

query_builder
// Trailing space required before the push values function
// Leading space required after the push values function
.push_values(self.iter(), |mut bind, (index, user_update)| {
bind.push_bind(index.user_id)
.push_bind("")
Expand All @@ -64,6 +64,8 @@ impl Flushable<UserUpdate> for super::Batch<Index, UserUpdate> {
.push_bind(user_update.downloaded_delta)
.push_bind("");
})
// Mysql 8.0.20 deprecates use of VALUES() so will have to update it eventually to use aliases instead
// However, Mariadb doesn't yet support aliases
.push(
r#"
ON DUPLICATE KEY UPDATE
Expand Down

0 comments on commit 636f076

Please sign in to comment.