0001-sql-add-possibility-to-drop-formdef-table-17524.patch
tests/test_sql.py | ||
---|---|---|
641 | 641 |
data_class = test_formdef.data_class(mode='sql') |
642 | 642 |
data_class.select() |
643 | 643 | |
644 |
@postgresql |
|
645 |
def test_sql_table_wipe_and_drop(): |
|
646 |
test_formdef = FormDef() |
|
647 |
test_formdef.name = 'tests wipe and drop' |
|
648 |
test_formdef.fields = [] |
|
649 |
test_formdef.store() |
|
650 |
assert test_formdef.table_name is not None |
|
651 |
data_class = test_formdef.data_class(mode='sql') |
|
652 |
assert data_class.count() == 0 |
|
653 |
conn, cur = sql.get_connection_and_cursor() |
|
654 |
assert table_exists(cur, test_formdef.table_name) |
|
655 |
conn.commit() |
|
656 |
cur.close() |
|
657 | ||
658 |
data_class.wipe(drop=True) |
|
659 |
conn, cur = sql.get_connection_and_cursor() |
|
660 |
assert not table_exists(cur, test_formdef.table_name) |
|
661 |
assert not table_exists(cur, test_formdef.table_name + '_evolutions') |
|
662 |
conn.commit() |
|
663 |
cur.close() |
|
664 | ||
665 |
test_formdef.store() |
|
666 |
conn, cur = sql.get_connection_and_cursor() |
|
667 |
assert table_exists(cur, test_formdef.table_name) |
|
644 | 668 | |
645 | 669 |
@postgresql |
646 | 670 |
def test_sql_table_select(): |
wcs/sql.py | ||
---|---|---|
1465 | 1465 |
cur.close() |
1466 | 1466 | |
1467 | 1467 |
@classmethod |
1468 |
@guard_postgres |
|
1469 |
def wipe(cls, drop=False): |
|
1470 |
conn, cur = get_connection_and_cursor() |
|
1471 |
if drop: |
|
1472 |
cur.execute('''DROP TABLE %s_evolutions CASCADE''' % cls._table_name) |
|
1473 |
cur.execute('''DROP TABLE %s CASCADE''' % cls._table_name) |
|
1474 |
else: |
|
1475 |
cur.execute('''DELETE FROM %s_evolutions''' % cls._table_name) |
|
1476 |
cur.execute('''DELETE FROM %s''' % cls._table_name) |
|
1477 |
conn.commit() |
|
1478 |
cur.close() |
|
1479 | ||
1480 |
@classmethod |
|
1468 | 1481 |
def do_tracking_code_table(cls): |
1469 | 1482 |
do_tracking_code_table() |
1470 | 1483 | |
1471 |
- |