These are chat archives for rails-sqlserver/activerecord-sqlserver-adapter

15th
Oct 2015
kenny
@yairgo
Oct 15 2015 14:23
hows it going
Ken Collins
@metaskills
Oct 15 2015 14:27
Hey!
kenny
@yairgo
Oct 15 2015 14:27
@metaskills what do you want me to do first? create a new migration with one column that has a default value?
Ken Collins
@metaskills
Oct 15 2015 14:27
Will be relocating and meeting today... so I can help on and off.
OK... so what SQL Server adapter are you using?
Or is this just TinyTDS?
kenny
@yairgo
Oct 15 2015 14:28
Using activerecord-sqlserver-adapter with tiny_tds
version 4.0.0 of adapter, 0.7.0 of tiny_tds
SQL Server 2008
Ken Collins
@metaskills
Oct 15 2015 14:29
Hmmm....
OK. So that version could have a bug in it.
kenny
@yairgo
Oct 15 2015 14:29
version 0.7.0?
Ken Collins
@metaskills
Oct 15 2015 14:29
No no
The adapter is 4.0.
Our latest is 4.2... and I remember some fixes around defaults around 4.1 or 4.2
I know you cant upgrade...
So let me look... and maybe we can fix in 4-0-stable for you.
kenny
@yairgo
Oct 15 2015 14:30
I don't want to say this definitively but I really don't think it is the adapter. We've tried out the latest version of the adapter and the issue is still there
Ken Collins
@metaskills
Oct 15 2015 14:30
OK... that really helps
We do have tests for this stuff too.
What are the default values?
kenny
@yairgo
Oct 15 2015 14:31
I traced down the code all the way to where the adapter tells tiny tds to give it back the table definitions
the defualt values are strings
Ken Collins
@metaskills
Oct 15 2015 14:31
Which would be adapter stuff.
kenny
@yairgo
Oct 15 2015 14:31
I've taken that SQL and ran it on SQL server and the results have defaults
Ken Collins
@metaskills
Oct 15 2015 14:32
Oh.
kenny
@yairgo
Oct 15 2015 14:32
When I create a TinyTds connection
Ken Collins
@metaskills
Oct 15 2015 14:32
Now how the heck could that happen.
kenny
@yairgo
Oct 15 2015 14:32
and run that sql, the result set does not have defaults
Ken Collins
@metaskills
Oct 15 2015 14:32
Maybe the user that is executing that SQL has different perms?
So there is nothing in TInyTDS that could prohibit.
Only thing I can think of is permissions.
kenny
@yairgo
Oct 15 2015 14:32
the connection i established with on the SQL server was the same user
but I could see how that could be it somehow
Ken Collins
@metaskills
Oct 15 2015 14:33
Can you explor that for a bit... and I will open up project locally and kick things around.
It would also help to know what the defaults are.
kenny
@yairgo
Oct 15 2015 14:33
there is a status column with the default of "pending"
Ken Collins
@metaskills
Oct 15 2015 14:33
Simple values or functions?
OK.
kenny
@yairgo
Oct 15 2015 14:34
yeah not functions. I saw a bug report on functinos
Ken Collins
@metaskills
Oct 15 2015 14:34
Gimmie a bit... I'll hit it from that side.
Maybe you can investigate permissions.
kenny
@yairgo
Oct 15 2015 14:34
Yeah I will try to do that.
I'm also gonna try to drop tiny_tds down to the previous version and see about that
Ken Collins
@metaskills
Oct 15 2015 14:35
You are in luck... I am at Microsoft / Redmond all this week :)
"they" are watching :eyes:
LOL
kenny
@yairgo
Oct 15 2015 14:35
lol
allright, I have a quick stand up then I'll hop on those 2 tasks and let you know the results.
Ken Collins
@metaskills
Oct 15 2015 14:36
BOOM
Ditto..
Ken Collins
@metaskills
Oct 15 2015 15:09
@yairgo So I can not see an issue here from a TinyTDS perspective. That SQL you posted is from the column_definitions method of the adapter. It is used to get default values to use for model objects to mirror what would happen in the DB on inserts.
The column_definitions does a lot of heavy lifting and is very user/schema sensitive. It has had love in recent 4.2 work...
See rails-sqlserver/activerecord-sqlserver-adapter@3fb340c
I really think permissions are the isue of the user executing the SQL. That said, if you feel the 4-0-stable branch needs some love that 4-2-stable got... I would be very open to that.
kenny
@yairgo
Oct 15 2015 15:29
I've traced it down to permissions as well
Any way you can help me address those :-O
Basically we have 2 different users, one with admin and one with crud. the admin user is used to run the migrations, app runs as the user with only crud.
It's just really weird that when I log onto the server the results are different from what tinytds gives me. Maybe when I'm on the sqlserver it gives slightly escalated privileges
Ken Collins
@metaskills
Oct 15 2015 15:59
Not sure I have some direct advice on the perms thing.
kenny
@yairgo
Oct 15 2015 15:59
@metaskills tracked it down. Was permissions. When the issue was shown to me, I took someones word for what it was and the query we were running on SQL Server was running in a window for the server admin user.
Ken Collins
@metaskills
Oct 15 2015 15:59
WOOHOO
Yea.. to solve it...
kenny
@yairgo
Oct 15 2015 15:59
At least we believe we did. Gonna recreate all of our users and roles from our script
Ken Collins
@metaskills
Oct 15 2015 15:59
I would have to "Bing" search for a few details on how perms work.
kenny
@yairgo
Oct 15 2015 15:59
We think we just had to give View Definition
Ken Collins
@metaskills
Oct 15 2015 15:59
Agreed.
Oh...
Lemme see...
kenny
@yairgo
Oct 15 2015 16:01
I don't know the security repercussions of that, but once we added that security right to the role, tiny_tds was pulling back the column definitions correctly.
Ken Collins
@metaskills
Oct 15 2015 16:02
Goes back to sb_helptext
We need to read that view to win it for ya.
At one time that was required and reaised an error.
But now we make it silently fail, which means you have a debug hole to jump in sometimes :(
Hmmm.... looks like we removed... one sec...
I just want to get my head back here...
kenny
@yairgo
Oct 15 2015 16:04
lol :) You think adding that security setting is ok though?
Ken Collins
@metaskills
Oct 15 2015 16:04
DOH
It is ok... it is sp_helptext
kenny
@yairgo
Oct 15 2015 16:04
ok cool
Ken Collins
@metaskills
Oct 15 2015 16:05
Yea... there is some scope I need to build up on where we are. Glad you found the issue too!
Cheer
kenny
@yairgo
Oct 15 2015 16:06
Yeah, I was afraid it might have been something on our side when google wasn't giving me any hits on bug results. Thanks for helping me work through it!!
Ken Collins
@metaskills
Oct 15 2015 16:43
rails-sqlserver/tiny_tds#162
Just closed that issue out. Thanks @saurabh500 and @sgrif for the discussion.
Gonna work on upgrading AppVeyor real quick and adding Azure to the CI builds...
Ken Collins
@metaskills
Oct 15 2015 17:02
We just got AppVeyor upgraded. So we can do more builds at once.
Also got in a new config to ignore dev.* branches.
Should have used that yesterday for my PRINT print_feature branch.
I have deleted that branch and created dev_print
Anyone want to pick that up?
Saurabh Singh
@saurabh500
Oct 15 2015 17:13
rails-sqlserver/tiny_tds#184
The ReadOnly intent is sent to the server as a byte in the Login phase of the connection with SQL Server.
This feature was introduced in TDS 7.4
fReadOnlyIntent
If FreeTDS supports this bit, then we need to expose a connection parameter called ApplicationIntent and honor it while sending it to FreeTDS
Ken Collins
@metaskills
Oct 15 2015 18:27
@saurabh500 Let's put those notes in that GitHub issue?
Ken Collins
@metaskills
Oct 15 2015 19:29
Just closed out rails-sqlserver/tiny_tds#228
By merging into master