(&self, _table: T, _index: I)
| 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 | |
| 162 | pub(crate) async fn has_table<C, T>(conn: &C, _table: T) -> Result<bool, DbErr> |
nothing calls this directly
no test coverage detected