Skip to content

Commit 17e48c0

Browse files
committed
Preserve the previous behaviour of transforming schema name to None if matches the default schema
1 parent d9dbb95 commit 17e48c0

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

diesel_cli/src/infer_schema_internals/information_schema.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,15 @@ where
176176
{
177177
use self::information_schema::tables::dsl::*;
178178

179+
let default_schema = Conn::Backend::default_schema(connection)?;
179180
let db_schema_name = match schema_name {
180-
Some(name) => Cow::Borrowed(name),
181-
None => Cow::Owned(Conn::Backend::default_schema(connection)?),
181+
Some(name) => name,
182+
None => &default_schema,
182183
};
183184

184185
let mut table_names = tables
185186
.select(table_name)
186-
.filter(table_schema.eq(db_schema_name.as_ref()))
187+
.filter(table_schema.eq(db_schema_name))
187188
.filter(table_name.not_like("\\_\\_%"))
188189
.filter(table_type.like("BASE TABLE"))
189190
.load::<String>(connection)?;
@@ -192,7 +193,9 @@ where
192193
.into_iter()
193194
.map(|name| TableName {
194195
name,
195-
schema: schema_name.map(|schema| schema.to_owned()),
196+
schema: schema_name
197+
.filter(|&schema| schema != default_schema)
198+
.map(|schema| schema.to_owned()),
196199
})
197200
.collect())
198201
}

0 commit comments

Comments
 (0)