from sqlconvert.process_mysql import remove_directive_tokens, \
is_directive_statement, requote_names, unescape_strings, \
process_statement
+from sqlconvert.process_tokens import escape_strings
def test_encoding():
assert query == u'SELECT * FROM "T"'
-def test_string():
- parsed = parse("insert into test values ('\"te\\'st\\\"')")[0]
+def test_unescape_string():
+ parsed = parse("insert into test values ('\"te\\'st\\\"\\n')")[0]
unescape_strings(parsed)
query = tlist2str(parsed)
- assert query == u"INSERT INTO test VALUES ('\"te''st\"')"
+ assert query == u"INSERT INTO test VALUES ('\"te'st\"\n')"
+
+
+def test_escape_string_postgres():
+ parsed = parse("insert into test values ('\"te\\'st\\\"\\n')")[0]
+ unescape_strings(parsed)
+ escape_strings(parsed, 'postgres')
+ query = tlist2str(parsed)
+ assert query == u"INSERT INTO test VALUES (E'\"te''st\"\\n')"
+
+
+def test_escape_string_sqlite():
+ parsed = parse("insert into test values ('\"te\\'st\\\"\\n')")[0]
+ unescape_strings(parsed)
+ escape_strings(parsed, 'sqlite')
+ query = tlist2str(parsed)
+ assert query == u"INSERT INTO test VALUES ('\"te''st\"\n')"
def test_process():