我正在尝试结合List<string> strings使用,string.Join(",", strings)但我正在阅读的所有内容都说我应该这样做:
string.Join(",", strings.ToArray())
我必须/应该使用某种原因.ToArray()吗?
我正在将数据从遗留系统传输到Django.为了确保当前数据库的完整性,我手动提交所有内容.
但是,在编写单元测试时,事务将无法正常回滚.既然TestCase可能正在使用事务,有没有办法在Django中正确测试依赖于事务的代码?
@transaction.commit_manually
def import_records():
# initial prep
try:
import_data()
except Exception as error:
rollback = True
except (KeyboardInterrupt, SystemExit):
sys.stdout.write("Import canceled\n")
rollback = True
if rollback is True:
transaction.rollback()
# save history of import
Run Code Online (Sandbox Code Playgroud)