Workspace SOA UNNEST
This commit is contained in:
parent
4efbb95204
commit
300ee37cf5
12
src/main.rs
12
src/main.rs
@ -179,22 +179,22 @@ impl Worker {
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.collect::<Result<Vec<_>, _>>()?;
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
|
||||||
for workspace in workspaces {
|
let workspaces = Soa::from(workspaces.as_slice());
|
||||||
|
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
r#"
|
r#"
|
||||||
INSERT INTO workspaces (id, organization_id, name)
|
INSERT INTO workspaces (id, organization_id, name)
|
||||||
VALUES ($1, $2, $3)
|
SELECT * FROM UNNEST($1::bigint[], $2::bigint[], $3::text[])
|
||||||
ON CONFLICT (id) DO UPDATE SET
|
ON CONFLICT (id) DO UPDATE SET
|
||||||
organization_id = excluded.organization_id,
|
organization_id = excluded.organization_id,
|
||||||
name = excluded.name
|
name = excluded.name
|
||||||
"#,
|
"#,
|
||||||
workspace.id as i64,
|
&workspaces.id().iter().map(|id| *id as i64).collect::<Vec<_>>()[..],
|
||||||
workspace.organization_id as i64,
|
&workspaces.organization_id().iter().map(|id| *id as i64).collect::<Vec<_>>()[..],
|
||||||
workspace.name,
|
workspaces.name(),
|
||||||
)
|
)
|
||||||
.execute(&mut self.db)
|
.execute(&mut self.db)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@ -580,7 +580,7 @@ pub mod types {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone, Soars)]
|
||||||
pub struct Workspace {
|
pub struct Workspace {
|
||||||
pub id: u64,
|
pub id: u64,
|
||||||
pub organization_id: u64,
|
pub organization_id: u64,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user