Skip to content

Commit 8c2566b

Browse files
committed
test: check migration type as well
1 parent 16b63cb commit 8c2566b

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

sqlx-core/src/migrate/migration_type.rs

+12
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ pub enum MigrationType {
1313
ReversibleDown,
1414
}
1515

16+
// It seems that deriving PartialEq leads to some weird lifetime bug I don't know why:
17+
//
18+
// `sqlx-core/src/postgres/copy.rs` then fails to compile with:
19+
// `associated function was supposed to return data with lifetime `'c` but it is returning data with lifetime `'1``
20+
//
21+
// Using a manual implementation seems to work however
22+
impl PartialEq for MigrationType {
23+
fn eq(&self, other: &Self) -> bool {
24+
core::mem::discriminant(self) == core::mem::discriminant(other)
25+
}
26+
}
27+
1628
impl MigrationType {
1729
pub fn from_filename(filename: &str) -> Self {
1830
if filename.ends_with(MigrationType::ReversibleUp.suffix()) {

tests/migrate/macro.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ async fn same_output() -> anyhow::Result<()> {
1212
for (e, r) in EMBEDDED.iter().zip(runtime.iter()) {
1313
assert_eq!(e.version, r.version);
1414
assert_eq!(e.description, r.description);
15+
assert_eq!(e.migration_type, r.migration_type);
1516
assert_eq!(e.sql, r.sql);
1617
assert_eq!(e.checksum, r.checksum);
1718
}

0 commit comments

Comments
 (0)