@@ -93,44 +93,43 @@ pub fn get_table_data(
93
93
domain_types_enabled : bool ,
94
94
) -> QueryResult < Vec < ColumnInformation > > {
95
95
use self :: information_schema:: columns:: dsl:: * ;
96
- use diesel:: sql_types:: { Nullable , SingleValue } ;
96
+ use diesel:: sql_types:: { Nullable , SingleValue , Text } ;
97
+
98
+ type BoxedTextExpr = Box < dyn BoxableExpression < columns , Pg , SqlType = Text > > ;
99
+ type BoxedMaybeTextExpr = Box < dyn BoxableExpression < columns , Pg , SqlType = Nullable < Text > > > ;
97
100
98
101
let schema_name = match table. schema {
99
102
Some ( ref name) => Cow :: Borrowed ( name) ,
100
103
None => Cow :: Owned ( Pg :: default_schema ( conn) ?) ,
101
104
} ;
102
105
103
- let query = if domain_types_enabled {
106
+ let ( select_name , select_schema ) = if domain_types_enabled {
104
107
define_sql_function ! ( #[ sql_name = "coalesce" ] fn coalesce_maybe<T : SingleValue >( x: Nullable <T >, y: Nullable <T >) -> Nullable <T >) ;
105
108
define_sql_function ! ( #[ sql_name = "coalesce" ] fn coalesce_strict<T : SingleValue >( x: Nullable <T >, y: T ) -> T ) ;
106
109
107
- columns
108
- . select ( (
109
- column_name,
110
- coalesce_strict ( domain_name, udt_name) ,
111
- coalesce_maybe ( domain_schema, udt_schema. nullable ( ) ) ,
112
- __is_nullable,
113
- character_maximum_length,
114
- col_description ( regclass ( table) , ordinal_position) ,
115
- ) )
116
- . filter ( table_name. eq ( & table. sql_name ) )
117
- . filter ( table_schema. eq ( schema_name) )
118
- . into_boxed ( )
110
+ (
111
+ Box :: new ( coalesce_strict ( domain_name, udt_name) ) as BoxedTextExpr ,
112
+ Box :: new ( coalesce_maybe ( domain_schema, udt_schema. nullable ( ) ) ) as BoxedMaybeTextExpr ,
113
+ )
119
114
} else {
120
- columns
121
- . select ( (
122
- column_name,
123
- udt_name,
124
- udt_schema. nullable ( ) ,
125
- __is_nullable,
126
- character_maximum_length,
127
- col_description ( regclass ( table) , ordinal_position) ,
128
- ) )
129
- . filter ( table_name. eq ( & table. sql_name ) )
130
- . filter ( table_schema. eq ( schema_name) )
131
- . into_boxed ( )
115
+ (
116
+ Box :: new ( udt_name) as BoxedTextExpr ,
117
+ Box :: new ( udt_schema. nullable ( ) ) as BoxedMaybeTextExpr ,
118
+ )
132
119
} ;
133
120
121
+ let query = columns
122
+ . select ( (
123
+ column_name,
124
+ select_name,
125
+ select_schema,
126
+ __is_nullable,
127
+ character_maximum_length,
128
+ col_description ( regclass ( table) , ordinal_position) ,
129
+ ) )
130
+ . filter ( table_name. eq ( & table. sql_name ) )
131
+ . filter ( table_schema. eq ( schema_name) ) ;
132
+
134
133
match column_sorting {
135
134
ColumnSorting :: OrdinalPosition => query. order ( ordinal_position) . load ( conn) ,
136
135
ColumnSorting :: Name => query. order ( column_name) . load ( conn) ,
0 commit comments