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

Method has_column

sea-orm-migration/src/manager.rs:107–132  ·  view source on GitHub ↗
(&self, _table: T, _column: C)

Source from the content-addressed store, hash-verified

105 }
106
107 pub async fn has_column<T, C>(&self, _table: T, _column: C) -> Result<bool, DbErr>
108 where
109 T: AsRef<str>,
110 C: AsRef<str>,
111 {
112 let _stmt: SelectStatement = match self.conn.get_database_backend() {
113 #[cfg(feature = "sqlx-mysql")]
114 DbBackend::MySql => sea_schema::mysql::MySql.has_column(_table, _column),
115 #[cfg(feature = "sqlx-postgres")]
116 DbBackend::Postgres => sea_schema::postgres::Postgres.has_column(_table, _column),
117 #[cfg(feature = "sqlx-sqlite")]
118 DbBackend::Sqlite => sea_schema::sqlite::Sqlite.has_column(_table, _column),
119 #[allow(unreachable_patterns)]
120 other => panic!("{other:?} feature is off"),
121 };
122
123 #[allow(unreachable_code)]
124 let builder = self.conn.get_database_backend();
125 let res = self
126 .conn
127 .query_one(builder.build(&_stmt))
128 .await?
129 .ok_or_else(|| DbErr::Custom("Failed to check column exists".to_owned()))?;
130
131 res.try_get("", "has_column")
132 }
133
134 pub async fn has_index<T, I>(&self, _table: T, _index: I) -> Result<bool, DbErr>
135 where

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