Use BIGSERIAL for postgres keys
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
This commit is contained in:
parent
0a8e2040ef
commit
3d66a82967
@ -138,7 +138,7 @@ WHERE table_name = $1
|
||||
|
||||
tx.execute(
|
||||
&format!(
|
||||
"CREATE TABLE {} (key SERIAL PRIMARY KEY, value JSONB NOT NULL);",
|
||||
"CREATE TABLE {} (key BIGSERIAL PRIMARY KEY, value JSONB NOT NULL);",
|
||||
Self::collection_name::<M>(),
|
||||
),
|
||||
&[],
|
||||
@ -191,7 +191,7 @@ where
|
||||
"SELECT (value) FROM {} WHERE key = $1;",
|
||||
Self::collection_name::<M>()
|
||||
),
|
||||
&[&id],
|
||||
&[&(id as i64)],
|
||||
)
|
||||
.map_err(Error::from)?
|
||||
.into_iter()
|
||||
@ -231,14 +231,12 @@ where
|
||||
eprintln!("insert done");
|
||||
|
||||
// Get the generated ID
|
||||
let id = row.get::<_, i32>("key") as u32;
|
||||
let id = row.get::<_, i64>("key") as u32;
|
||||
let mut value = row.get::<_, postgres::types::Json<M>>("value").0;
|
||||
// .map_err(Error::from)?;
|
||||
value.base_data_mut().id = id;
|
||||
|
||||
// NOTE: Update the value so the id is set correctly in the value itself
|
||||
// let ser_val = serde_json::to_string(&value).map_err(Error::from)?;
|
||||
|
||||
let updated = con
|
||||
.execute(
|
||||
&format!(
|
||||
@ -247,7 +245,7 @@ where
|
||||
),
|
||||
&[
|
||||
&postgres::types::Json(value.clone()),
|
||||
&(value.get_id() as i32),
|
||||
&(value.get_id() as i64),
|
||||
],
|
||||
)
|
||||
.map_err(Error::from)?;
|
||||
@ -266,7 +264,7 @@ where
|
||||
),
|
||||
&[
|
||||
&postgres::types::Json(value.clone()),
|
||||
&(value.get_id() as i32),
|
||||
&(value.get_id() as i64),
|
||||
],
|
||||
)
|
||||
.map_err(Error::from)?;
|
||||
@ -307,7 +305,7 @@ where
|
||||
"DELETE FROM {} WHERE key = $1;",
|
||||
Self::collection_name::<M>()
|
||||
),
|
||||
&[&id],
|
||||
&[&(id as i64)],
|
||||
)
|
||||
.map_err(Error::from)?;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user