@@ -379,6 +379,91 @@ mod tests {
379379 "# ) ;
380380 }
381381
382+ #[ test]
383+ fn test_maybe_buggy ( ) {
384+ let mut conn = TestConn :: default ( ) ;
385+ conn. sanitized_partition_map ( ) ;
386+
387+ assert_transact ! ( conn, r#"
388+ [{:db/ident :person/name :db/valueType :db.type/string :db/cardinality :db.cardinality/one}]
389+ "# ) ;
390+
391+ assert_transact ! ( conn, r#"[{:person/name "Ivan"}]"# ) ;
392+ assert_transact ! ( conn, r#"[{:person/name "Ivan"}]"# ) ;
393+
394+ assert_transact ! ( conn, r#"[[:db/add 65537 :person/name "Vanya"]]"# ) ;
395+
396+ // Move the last assertion away from the main timeline.
397+ let ( new_schema, new_partition_map) = move_from_main_timeline (
398+ & conn. sqlite , & conn. schema , conn. partition_map . clone ( ) ,
399+ conn. last_tx_id ( ) .., 1
400+ ) . expect ( "moved single tx" ) ;
401+ update_conn ( & mut conn, & new_schema, & new_partition_map) ;
402+
403+ // Assert that our datoms are now just the schema.
404+ assert_matches ! ( conn. datoms( ) , r#"
405+ [[?e :db/ident :person/name]
406+ [?e :db/valueType :db.type/string]
407+ [?e :db/cardinality :db.cardinality/one]
408+ [65537 :person/name "Ivan"]
409+ [65538 :person/name "Ivan"]]"# ) ;
410+ // Same for transactions.
411+ assert_matches ! ( conn. transactions( ) , r#"
412+ [[
413+ [?e :db/ident :person/name ?tx true]
414+ [?e :db/valueType :db.type/string ?tx true]
415+ [?e :db/cardinality :db.cardinality/one ?tx true]
416+ [?tx :db/txInstant ?ms ?tx true]
417+ ]
418+ [
419+ [65537 :person/name "Ivan" ?tx2 true]
420+ [?tx2 :db/txInstant ?ms2 ?tx2 true]
421+ ]
422+ [
423+ [65538 :person/name "Ivan" ?tx3 true]
424+ [?tx3 :db/txInstant ?ms3 ?tx3 true]
425+ ]]"# ) ;
426+
427+ assert_transact ! ( conn, r#"
428+ [[:db/retract 65537 :person/name "Ivan"]]"# ) ;
429+
430+ assert_transact ! ( conn, r#"
431+ [[:db/retract "65537" :person/name "Ivan"]
432+ [:db/add "65537" :person/name "Vanya"]]"# ) ;
433+
434+ // Assert that our datoms are now the schema and the final assertion.
435+ assert_matches ! ( conn. datoms( ) , r#"
436+ [[?e1 :db/ident :person/name]
437+ [?e1 :db/valueType :db.type/string]
438+ [?e1 :db/cardinality :db.cardinality/one]
439+ [65538 :person/name "Ivan"]
440+ [65539 :person/name "Vanya"]]
441+ "# ) ;
442+
443+ // Assert that we have three correct looking transactions.
444+ // This will fail if we're not cleaning up the 'datoms' table
445+ // after the timeline move.
446+ assert_matches ! ( conn. transactions( ) , r#"
447+ [[
448+ [?e1 :db/ident :person/name ?tx1 true]
449+ [?e1 :db/valueType :db.type/string ?tx1 true]
450+ [?e1 :db/cardinality :db.cardinality/one ?tx1 true]
451+ [?e1 :db/unique :db.unique/identity ?tx1 true]
452+ [?e1 :db/index true ?tx1 true]
453+ [?tx1 :db/txInstant ?ms1 ?tx1 true]
454+ ]
455+ [
456+ [?e2 :person/name "Vanya" ?tx2 true]
457+ [?tx2 :db/txInstant ?ms2 ?tx2 true]
458+ ]
459+ [
460+ [?e2 :person/name "Ivan" ?tx3 true]
461+ [?e2 :person/name "Vanya" ?tx3 false]
462+ [?tx3 :db/txInstant ?ms3 ?tx3 true]
463+ ]]
464+ "# ) ;
465+ }
466+
382467 #[ test]
383468 fn test_pop_schema ( ) {
384469 let mut conn = TestConn :: default ( ) ;
@@ -494,7 +579,7 @@ mod tests {
494579 "# ) ;
495580 }
496581
497- #[ test]
582+ #[ test]
498583 fn test_pop_schema_all_attributes_component ( ) {
499584 let mut conn = TestConn :: default ( ) ;
500585 conn. sanitized_partition_map ( ) ;
0 commit comments