Skip to content

Commented out semicolon NOT ignored#190

Closed
bertl wants to merge 1 commit intonpgsql:masterfrom
bertl:master
Closed

Commented out semicolon NOT ignored#190
bertl wants to merge 1 commit intonpgsql:masterfrom
bertl:master

Conversation

@bertl
Copy link

@bertl bertl commented Mar 20, 2014

If there is a semicolon within a single line comment "--", Npgsql
assumes that it marks the end of a statement and starts the next
statement (chunk) immediately after it, ignoring that this is still
commented out.
This commit ignores semicolons within single line comments.

I have created a test demonstrating the issue:
This will throw an exception although the command is valid (though meaningless in this case)

[Test]
public void CommentedOutSemicolon()
{
  var command = new NpgsqlCommand("-- 1\n-- 2; abc\n-- 3;", Conn);
  command.ExecuteNonQuery();
}

If there is a semicolon within a single line comment "--", Npgsql
assumes that it marks the end of a statement and starts the next
statement (chunk) immediately after it, ignoring that this is still
commented out.
This commit ignores semicolons within single line comments.
glenebob added a commit that referenced this pull request Mar 29, 2014
Add test from issue #190, plus a couple more, to demonstrate rewriter broken by certain comments.
@glenebob
Copy link
Contributor

Hi @bertl,

I added your test, and a couple others, to the project.

I then fixed the query re-writer to handle comments properly. So far, these changes are only in master.

Please, if you would, grab the latest sources and see if my changes work for you. I expect this will be merged in 2.1 soon.

Thanks!

-Glen

@bertl
Copy link
Author

bertl commented Mar 31, 2014

Hi @glenebob,

thanks for fixing this! Your change looks good and seems to work fine. Nice that you are now also "cutting" out block comments.

Cheers!

@bertl bertl closed this Mar 31, 2014
glenebob added a commit that referenced this pull request Apr 5, 2014
Add test from issue #190, plus a couple more, to demonstrate rewriter broken by certain comments (cherry picked from master).
@glenebob
Copy link
Contributor

glenebob commented Apr 5, 2014

Fixed in master and 2.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants