@@ -374,6 +374,55 @@ def test_delete_then_recreate_same_name_resolves_operations_in_order(catalog) ->
374374 )["valid" ] is True
375375
376376
377+ def test_temporary_created_target_can_be_deleted_before_final_schema (catalog ) -> None :
378+ url , path , dataset_id , table_name = catalog
379+
380+ openstatspec .apply_spss_in_place (
381+ database_url = url ,
382+ dataset_id = dataset_id ,
383+ source_text = "COMPUTE tmp = score. DELETE VARIABLES tmp." ,
384+ actor = "test-agent" ,
385+ )
386+
387+ connection = sqlite3 .connect (path )
388+ assert connection .execute (
389+ "select source_name, source_ordinal from variable "
390+ "where dataset_id = ? order by source_ordinal" ,
391+ (dataset_id ,),
392+ ).fetchall () == [("score" , 1 )]
393+ assert [
394+ row [1 ] for row in connection .execute (f'PRAGMA table_info("{ table_name } ")' )
395+ ] == ["__case_ordinal" , "score" ]
396+ connection .close ()
397+
398+
399+ def test_temporary_target_type_is_not_taken_from_same_name_recreation (catalog ) -> None :
400+ url , path , dataset_id , table_name = catalog
401+
402+ openstatspec .apply_spss_in_place (
403+ database_url = url ,
404+ dataset_id = dataset_id ,
405+ source_text = (
406+ "COMPUTE tmp = score. DELETE VARIABLES tmp. STRING tmp (A4)."
407+ ),
408+ actor = "test-agent" ,
409+ )
410+
411+ connection = sqlite3 .connect (path )
412+ assert connection .execute (
413+ "select source_name, storage_kind, declared_string_width "
414+ "from variable where dataset_id = ? order by source_ordinal" ,
415+ (dataset_id ,),
416+ ).fetchall () == [("score" , "numeric" , None ), ("tmp" , "string" , 4 )]
417+ assert connection .execute (
418+ f'SELECT score, tmp FROM "{ table_name } " ORDER BY __case_ordinal'
419+ ).fetchall () == [(1.0 , "" ), (2.0 , "" ), (3.0 , "" )]
420+ connection .close ()
421+ assert validate_wide_dataset (
422+ database_url = url , dataset_id = dataset_id ,
423+ )["valid" ] is True
424+
425+
377426def test_public_apply_supports_non_dolt_without_building_undo (catalog ) -> None :
378427 url , path , dataset_id , table_name = catalog
379428 plan = _plan ("RECODE score (1 = 0)." )
0 commit comments