33use crate :: {
44 getters:: Getter , ids:: * , parsers:: Parser , Column , ColumnArity , ColumnType , ColumnTypeFamily , DefaultValue ,
55 DescriberError , DescriberErrorKind , DescriberResult , ForeignKeyAction , IndexColumn , Procedure , SQLSortOrder ,
6- SqlMetadata , SqlSchema , UserDefinedType , View ,
6+ SqlSchema , UserDefinedType , View ,
77} ;
88use either:: Either ;
99use enumflags2:: BitFlags ;
@@ -16,7 +16,7 @@ use psl::{
1616} ;
1717use quaint:: prelude:: Queryable ;
1818use regex:: Regex ;
19- use std:: { any:: type_name, borrow:: Cow , collections:: HashMap , convert :: TryInto , sync:: LazyLock } ;
19+ use std:: { any:: type_name, borrow:: Cow , collections:: HashMap , sync:: LazyLock } ;
2020
2121/// Matches a default value in the schema, that is not a string.
2222///
@@ -103,24 +103,6 @@ impl std::fmt::Debug for SqlSchemaDescriber<'_> {
103103
104104#[ async_trait:: async_trait]
105105impl super :: SqlSchemaDescriberBackend for SqlSchemaDescriber < ' _ > {
106- async fn list_databases ( & self ) -> DescriberResult < Vec < String > > {
107- Ok ( self . get_databases ( ) . await ?)
108- }
109-
110- async fn get_metadata ( & self , schema : & str ) -> DescriberResult < SqlMetadata > {
111- let mut sql_schema = SqlSchema :: default ( ) ;
112-
113- self . get_namespaces ( & mut sql_schema, & [ schema] ) . await ?;
114-
115- let table_count = self . get_table_names ( & mut sql_schema) . await ?. len ( ) ;
116- let size_in_bytes = self . get_size ( schema) . await ?;
117-
118- Ok ( SqlMetadata {
119- table_count,
120- size_in_bytes,
121- } )
122- }
123-
124106 async fn describe ( & self , schemas : & [ & str ] ) -> DescriberResult < SqlSchema > {
125107 let mut sql_schema = SqlSchema :: default ( ) ;
126108 let mut mssql_ext = MssqlSchemaExt :: default ( ) ;
@@ -157,12 +139,6 @@ impl<'a> SqlSchemaDescriber<'a> {
157139 Self { conn }
158140 }
159141
160- async fn get_databases ( & self ) -> DescriberResult < Vec < String > > {
161- let sql = "SELECT name FROM sys.schemas" ;
162- let rows = self . conn . query_raw ( sql, & [ ] ) . await ?;
163- Ok ( rows. into_iter ( ) . map ( |row| row. get_expect_string ( "name" ) ) . collect ( ) )
164- }
165-
166142 async fn get_procedures ( & self , sql_schema : & mut SqlSchema ) -> DescriberResult < ( ) > {
167143 let sql = r#"
168144 SELECT
@@ -232,36 +208,6 @@ impl<'a> SqlSchemaDescriber<'a> {
232208 Ok ( map)
233209 }
234210
235- async fn get_size ( & self , schema : & str ) -> DescriberResult < usize > {
236- let sql = indoc ! { r#"
237- SELECT
238- SUM(a.total_pages) * 8000 AS size
239- FROM
240- sys.tables t
241- INNER JOIN
242- sys.partitions p ON t.object_id = p.object_id
243- INNER JOIN
244- sys.allocation_units a ON p.partition_id = a.container_id
245- WHERE SCHEMA_NAME(t.schema_id) = @P1
246- AND t.is_ms_shipped = 0
247- GROUP BY
248- t.schema_id
249- ORDER BY
250- size DESC;
251- "# } ;
252-
253- let rows = self . conn . query_raw ( sql, & [ schema. into ( ) ] ) . await ?;
254-
255- let size: i64 = rows
256- . into_single ( )
257- . map ( |row| row. get ( "size" ) . and_then ( |x| x. as_integer ( ) ) . unwrap_or ( 0 ) )
258- . unwrap_or ( 0 ) ;
259-
260- Ok ( size
261- . try_into ( )
262- . expect ( "Invariant violation: size is not a valid usize value." ) )
263- }
264-
265211 async fn get_columns ( & self , sql_schema : & mut SqlSchema ) -> DescriberResult < ( ) > {
266212 let sql = indoc ! { r#"
267213 SELECT c.name AS column_name,
0 commit comments