Skip to content

Commit

Permalink
use sql from sqlite_master for checking table definition
Browse files Browse the repository at this point in the history
  • Loading branch information
kyoto7250 committed Jun 30, 2024
1 parent 109df23 commit 8e466b3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/database/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,11 @@ impl Pool for SqlitePool {
Ok(foreign_keys)
}

async fn get_definition(&self, database: &Database, table: &Table) -> anyhow::Result<String> {
let query = format!("SHOW CREATE TABLE `{}`.`{}`;", database.name, table.name);
let row = sqlx::query(query.as_str()).fetch_one(&self.pool).await?;
Ok(row.get::<String, usize>(1))
async fn get_definition(&self, _database: &Database, table: &Table) -> anyhow::Result<String> {
let query = sqlx::query("SELECT sql FROM sqlite_master WHERE type='table' AND name=?;")
.bind(&table.name);
let row = query.fetch_one(&self.pool).await?;
Ok(row.get::<String, usize>(0))
}
async fn close(&self) {
self.pool.close().await;
Expand Down

0 comments on commit 8e466b3

Please sign in to comment.