Skip to content

Commit

Permalink
Merge pull request #87 from kyoto7250/issue-86
Browse files Browse the repository at this point in the history
use sql from sqlite_master for checking table definition
  • Loading branch information
kyoto7250 authored Jun 30, 2024
2 parents 109df23 + 8e466b3 commit ec8bf76
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 ec8bf76

Please sign in to comment.