-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MS SQL Server: handle columns with spaces #234
Conversation
Added an override of the buildInsertCommand method on the SqlServerEnvironment object. The method simply surrounds the column names with brackets. I.E. INSERT INTO <some table>([COLUMN1],[COLUMN TWO],[COLUMN3])... instead of INSERT INTO <some table>(COLUMN1,COLUMN TWO, COLUMN3)...
Hi @mitchelldavis, thanks for the patch! To stop this case from regressing in the future:
|
values.append(comma); | ||
//This will allow column names that have spaces or are keywords. | ||
sb.append("[" + accessor.getName() + "]"); | ||
//sb.append(accessor.getName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you could get rid of these commented out code lines, that'd be great - no point in carrying around unused code.
I'm on it. |
I've added some tests for the @javornikolov: I didn't implement your suggestion on pulling out the Any suggestions on how to quickly implement what your suggesting would be appreciated. |
Darn, I hit the wrong button.... Sorry. :-) |
Thanks @mitchelldavis! We'll review. Another request/question - have you managed to run the tests locally (the new ones and the whole suite for MS SQL Server)? We're lacking MS SQL Server environments so it's a bit hard to test it properly but if you can give some feedback, that would be great. |
I was able to run the integration tests locally: However, the acceptance tests I had to do a little rigging for and on that note, I only ran the one I wrote. Below is the actual test I ran.
I wasn't sure how to get all of the acceptance tests running on my windows machine.
So, other than connectivity (which it seemed is being handled outside of most of your acceptance tests) the test is self containing, so I made sure that I was able to successfully get the above test to pass and fail, then committed it minus the first three lines. The environment I used to get it to pass and fail was an in house one referencing the updated *.jar files. In house, we use a combination of MSBuild, http://www.liquibase.org/, and DbFit for our database projects, With some neat build scripts it's working pretty well for us. What specifically are you looking for feedback on? DbFit seems to be working great with SQLServer so far (other than the issue this pull request is for. ;-)). I'll try porting over all the tests into our environment, but maybe you could give me a hint on why |
java -cp 'lib\dbfit-docs-2.2.0.jar:lib\fitnesse-standalone-20140122.jar' fitnesseMain.FitNesseMain
Error: Could not find or load main class fitnesseMain.FitNesseMain For this one - seems we have a bug: path separator should be |
That last pull didn't really fix the issue. I can run |
FYI, I'm finding issues with my acceptance test. I'll let you know when I get them resolved. |
I fixed that in #236. Thanks a lot for catching the issues with
I'm glad to hear DbFit works well for you :-) Since we don't build and test DbFit on MS SQL Server (nor on Windows) there is higher risk for glitches there. So I wondered: are the acceptance tests still passing OK for SQL Server. |
Thanks for those two pulls, I was able to finally get Here's the status of the...DotNetTests.SqlServerTests: (I don't have a copy of SQLServer 2000 or DB2)
However, they're actually all failing. I noticed within the gradle build...
... that the .\dist\fitsharp directory is not populated with current .net builds of the code on I made these changes in .\FitnesseRoot\DbFit\AcceptanceTests\DotNetTests\SqlServerTests\FlowMode\SetUp\content.txt:
and .\FitnessRoot\DbFit\AcceptanceTests\DotNetTests\content.txt:
In order to get the tests to run with the default java runner and against the current code base. I also, removed the changes that I originally submitted for the Pull Request and re-ran the tests and got the following results:
So, long story short: I can prove that my acceptance test passes, but I cannot prove that it doesn't cause any regressions in other code. So, where do we go from here? I would really like this pull to get through because we would like to not have to rely on a local build of dbfit for our build server. However, I understand that we could be introducing some bad stuff. |
Crap, saw an error... Here are the actual test numbers that should replace that second set of test numbers above:
Which matches the original set of test numbers. This quasi-proves that the pull's changes won't cause any issues. |
@mitchelldavis thanks for investigating. The reason why you had to hack However the versions share tests, so you ended up running the correct test suite in the end. Now, the final tweak that I think is needed is to add a symbolic link to the new test into the SQLServer java testsuite - it's possible to either do that by hand, or through the properties of the Apart from that, obviously it's not ideal that the test suite doesn't pass entirely, but that's not due to this change, so I'm inclined to merge it after the above change has been made. @javornikolov what do you think? |
Yes, I think the change is OK to be merged 👍 It seems to be a different topic what are these exceptions raising failures/exceptions: doesn't seem related to this change. |
One question came to my mind: @mitchelldavis, could you confirm that enclosing a column name into '[]' doesn't make it case sensitive? |
this comment on stackoverflow seems to suggest that the answer is "not necessarily" |
OK. As far as I understand, case sensitivity is determined by db configuration and is not dependent on surrounding names in square brackets. Good, so this change is not supposed to break anything. (My concern was that it may behave double quotes in Oracle where "MyColumn" would make name case sensitive.) |
Thanks for all your patience and help with this @benilovj and @javornikolov. Let me know if I can be of any help in the future. |
@mitchelldavis thank you for your contribution! I hope to push out a release including this change soon (within a week) |
@mitchelldavis I'd have normally sent you a link to a build that included your change, but unfortunately it seems that the package publishing functionality of our CI build is broken at the moment. |
Sounds great. Thank you @benilovj. |
|Execute|Create table Test_DBFit(name varchar(50), [lucky Number] int)| | ||
|
||
|Insert|Test_DBFit| | ||
|name|luckyNumber| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that with a bit of delay but I think here it should be: lucky Number
instead of luckyNumber
.
The reason I got into that again - I was thinking about a similar issue in Oracle and I started wondering about an alternative solution - explicitly enclosing the column names in test itself.
|Insert|Test_DBFit|
|name|[lucky Number]|
...
@mitchelldavis, have you tried it that way?
@javornikolov see #238 |
Added an override of the buildInsertCommand method on the
SqlServerEnvironment object. The method simply surrounds the column
names with brackets.
For Example:
INSERT INTO ([COLUMN1],[COLUMN TWO],[COLUMN3])...
instead of:
INSERT INTO (COLUMN1,COLUMN TWO, COLUMN3)... which causes an error.