big features
This commit is contained in:
@@ -11,11 +11,11 @@ use sqlx::{Any, Transaction};
|
||||
|
||||
async fn inserted_id(kind: DatabaseKind, tx: &mut Transaction<'_, Any>, table: &str) -> Result<i64, sqlx::Error> {
|
||||
let query = match kind {
|
||||
DatabaseKind::Sqlite => "SELECT last_insert_rowid()",
|
||||
DatabaseKind::MySql => "SELECT LAST_INSERT_ID()",
|
||||
DatabaseKind::Sqlite => queries::SQLITE_LAST_INSERT_ID,
|
||||
DatabaseKind::MySql => queries::MYSQL_LAST_INSERT_ID,
|
||||
DatabaseKind::Postgres => match table {
|
||||
"note_revisions" => "SELECT currval(pg_get_serial_sequence('note_revisions', 'id'))",
|
||||
"revisions" => "SELECT currval(pg_get_serial_sequence('revisions', 'id'))",
|
||||
"note_revisions" => queries::POSTGRES_NOTE_REVISION_LAST_INSERT_ID,
|
||||
"revisions" => queries::POSTGRES_PAD_REVISION_LAST_INSERT_ID,
|
||||
_ => unreachable!("unsupported identity table"),
|
||||
},
|
||||
};
|
||||
@@ -36,7 +36,8 @@ pub struct Workspace {
|
||||
pub struct Note {
|
||||
pub id: i64,
|
||||
#[serde(skip_serializing)]
|
||||
pub workspace_id: i64,
|
||||
#[sqlx(rename = "workspace_id")]
|
||||
pub _workspace_id: i64,
|
||||
pub slug: String,
|
||||
pub title: String,
|
||||
#[serde(skip_serializing)]
|
||||
@@ -66,7 +67,7 @@ impl From<SqliteNote> for Note {
|
||||
fn from(value: SqliteNote) -> Self {
|
||||
Self {
|
||||
id: value.id,
|
||||
workspace_id: value.workspace_id,
|
||||
_workspace_id: value.workspace_id,
|
||||
slug: value.slug,
|
||||
title: value.title,
|
||||
content: value.content,
|
||||
|
||||
Reference in New Issue
Block a user