MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / has_table

Function has_table

sea-orm-migration/src/manager.rs:162–186  ·  view source on GitHub ↗
(conn: &C, _table: T)

Source from the content-addressed store, hash-verified

160}
161
162pub(crate) async fn has_table<C, T>(conn: &C, _table: T) -> Result<bool, DbErr>
163where
164 C: ConnectionTrait,
165 T: AsRef<str>,
166{
167 let _stmt: SelectStatement = match conn.get_database_backend() {
168 #[cfg(feature = "sqlx-mysql")]
169 DbBackend::MySql => sea_schema::mysql::MySql.has_table(_table),
170 #[cfg(feature = "sqlx-postgres")]
171 DbBackend::Postgres => sea_schema::postgres::Postgres.has_table(_table),
172 #[cfg(feature = "sqlx-sqlite")]
173 DbBackend::Sqlite => sea_schema::sqlite::Sqlite.has_table(_table),
174 #[allow(unreachable_patterns)]
175 other => panic!("{other:?} feature is off"),
176 };
177
178 #[allow(unreachable_code)]
179 let builder = conn.get_database_backend();
180 let res = conn
181 .query_one(builder.build(&_stmt))
182 .await?
183 .ok_or_else(|| DbErr::Custom("Failed to check table exists".to_owned()))?;
184
185 res.try_get("", "has_table")
186}

Callers 1

has_tableMethod · 0.85

Calls 5

has_tableMethod · 0.80
get_database_backendMethod · 0.45
query_oneMethod · 0.45
buildMethod · 0.45
try_getMethod · 0.45

Tested by

no test coverage detected