Batch Splitter: Handle trailing comments with single quotes. #108

Merged
merged 2 commits into from Mar 23, 2013

Conversation

Projects
None yet
2 participants
@mpareja
Member

mpareja commented Mar 23, 2013

There was a nasty bug in the SQL Server batch splitting regex which caused batches to be split incorrectly. Consider the following contrived example SQL:

select first_name, last_name -- don't bother with middle name
from person
GO
select first_name + ' ' + last_name

The statement splitter would not detect the GO statement because it incorrectly considered the single quote in the trailing comment as a string.

I tightened up the regex and made it a bit more legible for future readers.

mpareja added some commits Mar 20, 2013

Handle trailing comments with single quotes.
+ If a trailing comment contains a single quote and the following SQL batch contains a single quote, roundhouse was not recognizing them as separate batches.
+ Split the regex up to make it easier for the next person looking at it to understand.

@mpareja mpareja merged commit 4156cff into master Mar 23, 2013

@mpareja mpareja deleted the splitter branch Mar 23, 2013

@ferventcoder

This comment has been minimized.

Show comment
Hide comment
@ferventcoder

ferventcoder Mar 23, 2013

Member

Looks good. I just pulled that code in to simplify the original regex, which was failing on some code I had. Thought it was good (leaning on tests, but guess I didn't have enough). Thanks for finding this. Wonder how it works when you have -- inside of the single quote marks. Someone had this...

Member

ferventcoder commented Mar 23, 2013

Looks good. I just pulled that code in to simplify the original regex, which was failing on some code I had. Thought it was good (leaning on tests, but guess I didn't have enough). Thanks for finding this. Wonder how it works when you have -- inside of the single quote marks. Someone had this...

@mpareja

This comment has been minimized.

Show comment
Hide comment
@mpareja

mpareja Mar 23, 2013

Member

I believe his issue has been around since a297dd4. I ran into it a while back but we were running a custom build of Roundhouse and I hadn't had time to look at it, so we hadn't updated due to it. It's been on my conscience for a while, so it was definitely something high on my to-do list! I expected it should handle that fine, but better safe than sorry, so I ran it against the original issue in https://code.google.com/p/roundhouse/issues/detail?id=71 and it came out as expected:

INSERT [dbo].[Foo] ([Bar]) VALUES (N'hello--world.
Thanks!')
INSERT [dbo].[Foo] ([Bar]) VALUES (N'Go speed racer, go speed racer, go speed racer go!!!!! ')
Member

mpareja commented Mar 23, 2013

I believe his issue has been around since a297dd4. I ran into it a while back but we were running a custom build of Roundhouse and I hadn't had time to look at it, so we hadn't updated due to it. It's been on my conscience for a while, so it was definitely something high on my to-do list! I expected it should handle that fine, but better safe than sorry, so I ran it against the original issue in https://code.google.com/p/roundhouse/issues/detail?id=71 and it came out as expected:

INSERT [dbo].[Foo] ([Bar]) VALUES (N'hello--world.
Thanks!')
INSERT [dbo].[Foo] ([Bar]) VALUES (N'Go speed racer, go speed racer, go speed racer go!!!!! ')
@ferventcoder

This comment has been minimized.

Show comment
Hide comment
@ferventcoder

ferventcoder Mar 23, 2013

Member

That commit definitely caused an issue. But I did take in a pull request around a month ago that may have brought new items. I was hoping it fixed some of the other issues but hadn't had a chance yet to look around. https://groups.google.com/forum/?hl=en&fromgroups=#!searchin/chucknorrisframework/hangs$20regex/chucknorrisframework/wOdQOMXxmNM/HtsXYiJ_EjYJ

It appears I may have have it backwards. The --comments then the ' mark.

Member

ferventcoder commented Mar 23, 2013

That commit definitely caused an issue. But I did take in a pull request around a month ago that may have brought new items. I was hoping it fixed some of the other issues but hadn't had a chance yet to look around. https://groups.google.com/forum/?hl=en&fromgroups=#!searchin/chucknorrisframework/hangs$20regex/chucknorrisframework/wOdQOMXxmNM/HtsXYiJ_EjYJ

It appears I may have have it backwards. The --comments then the ' mark.

@ferventcoder

This comment has been minimized.

Show comment
Hide comment
@ferventcoder

ferventcoder Mar 23, 2013

Member

The stuff in 71 was definitely fixed then, but it cropped up this issue: --don't forget to do something and messing up on that.

Member

ferventcoder commented Mar 23, 2013

The stuff in 71 was definitely fixed then, but it cropped up this issue: --don't forget to do something and messing up on that.

@ferventcoder

This comment has been minimized.

Show comment
Hide comment
@ferventcoder

ferventcoder Mar 23, 2013

Member

And you've now fixed that. :)

Member

ferventcoder commented Mar 23, 2013

And you've now fixed that. :)

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