Revision 2710
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
792 | 792 |
WHEN data_exception THEN |
793 | 793 |
''' |
794 | 794 |
if save_errors: |
795 |
col_names = map(sql_gen.Literal, srcs)
|
|
795 |
cols = [sql_gen.Literal(c.name) for c in srcs]
|
|
796 | 796 |
query += '''\ |
797 | 797 |
-- Save error in errors table. |
798 | 798 |
BEGIN |
799 | 799 |
INSERT INTO '''+errors_table.to_str(db)+''' |
800 | 800 |
("column", value, error) |
801 |
(VALUES '''+(', '.join(('('+c.to_str(db)+')' for c in col_names)) |
|
801 |
SELECT * |
|
802 |
FROM (VALUES '''+(', '.join(('('+c.to_str(db)+')' for c in cols)) |
|
802 | 803 |
)+''') AS c |
803 |
CROSS JOIN |
|
804 |
(VALUES (value, SQLERRM)) AS v |
|
804 |
CROSS JOIN (VALUES (value, SQLERRM)) AS v |
|
805 | 805 |
; |
806 | 806 |
EXCEPTION |
807 | 807 |
WHEN unique_violation THEN NULL; -- ignore duplicate key |
Also available in: Unified diff
sql.py: cast(): save_errors: Fixed bug where srcs needed to have their names extracted before being wrapped in sql_gen.Literals. Fixed bug where errors table INSERT needed to prefix the CROSS JOIN-ed VALUES statements with SELECT * FROM because the CROSS JOIN makes it a whole SELECT query, not just a VALUES statement.