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

Method has_index

sea-orm-migration/src/manager.rs:134–159  ·  view source on GitHub ↗
(&self, _table: T, _index: I)

Source from the content-addressed store, hash-verified

132 }
133
134 pub async fn has_index<T, I>(&self, _table: T, _index: I) -> Result<bool, DbErr>
135 where
136 T: AsRef<str>,
137 I: AsRef<str>,
138 {
139 let _stmt: SelectStatement = match self.conn.get_database_backend() {
140 #[cfg(feature = "sqlx-mysql")]
141 DbBackend::MySql => sea_schema::mysql::MySql.has_index(_table, _index),
142 #[cfg(feature = "sqlx-postgres")]
143 DbBackend::Postgres => sea_schema::postgres::Postgres.has_index(_table, _index),
144 #[cfg(feature = "sqlx-sqlite")]
145 DbBackend::Sqlite => sea_schema::sqlite::Sqlite.has_index(_table, _index),
146 #[allow(unreachable_patterns)]
147 other => panic!("{other:?} feature is off"),
148 };
149
150 #[allow(unreachable_code)]
151 let builder = self.conn.get_database_backend();
152 let res = self
153 .conn
154 .query_one(builder.build(&_stmt))
155 .await?
156 .ok_or_else(|| DbErr::Custom("Failed to check index exists".to_owned()))?;
157
158 res.try_get("", "has_index")
159 }
160}
161
162pub(crate) async fn has_table<C, T>(conn: &C, _table: T) -> Result<bool, DbErr>

Callers

nothing calls this directly

Calls 4

get_database_backendMethod · 0.45
query_oneMethod · 0.45
buildMethod · 0.45
try_getMethod · 0.45

Tested by

no test coverage detected