Skip to content

Commit f025f71

Browse files
authored
Merge pull request #245
fix #243 - parsing SQL scripts with semicolons and escaped single quotes
2 parents 87fc583 + afdeb6d commit f025f71

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/DatabaseLibrary/query.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,6 @@ def execute_sql_script(
346346
# check if the semicolon is a part of the value (quoted string)
347347
quotes += sqlFragment.count("'")
348348
quotes -= sqlFragment.count("\\'")
349-
quotes -= sqlFragment.count("''")
350349
inside_quoted_string = quotes % 2 != 0
351350
if inside_quoted_string:
352351
sqlFragment += ";" # restore the semicolon
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
INSERT INTO person VALUES(5, 'Miles', 'O''Brian');
1+
INSERT INTO person VALUES(5, 'Miles', 'O''Brian');
2+
INSERT INTO person VALUES(6, 'Keiko', 'O''Brian');

test/tests/common_tests/script_files.robot

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ Semicolons In Values
2929
Semicolons And Quotes In Values
3030
Run SQL Script File semicolons_and_quotes_in_values
3131
${sql}= Catenate select * from person
32-
... where id=5
32+
... where LAST_NAME='O''Brian'
3333
${results}= Query ${sql}
34-
Length Should Be ${results} 1
34+
Length Should Be ${results} 2
3535
Should Be Equal As Strings ${results}[0] (5, 'Miles', "O'Brian")
36+
Should Be Equal As Strings ${results}[1] (6, 'Keiko', "O'Brian")
3637

3738

3839
*** Keywords ***

0 commit comments

Comments
 (0)