将SQL 2014支持添加到activerecord-sqlserver-adapter [英] Add SQL 2014 support to activerecord-sqlserver-adapter

查看:104
本文介绍了将SQL 2014支持添加到activerecord-sqlserver-adapter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经在sqlserver 2008中使用了activerecord-sqlserver-adapter gem,并且一切正常.我们只是尝试针对新的sqlserver 2014数据库部署Rails 3应用程序,但出现错误消息:

We've be using the activerecord-sqlserver-adapter gem with sqlserver 2008 and everything works great. We just tried to deploy our Rails 3 app against a new sqlserver 2014 db and I get an error that says:

Currently, only 2005, 2008, 2010, 2011, and 2012 are supported. We got back Microsoft SQL Server 2014 - 12.0.2000.8 (X64)

对github的快速浏览显示,最近对sqlserver_adapter.rd进行了小幅更新以解决此问题.我试图更新gem,它变成了一点依赖地狱,最终看起来好像我必须升级到rails 4(我现在不特别想这样做)才能获得此修复程序.

A quick look at github shows that a small update was recently made to the sqlserver_adapter.rd to resolve this issue. I tried to update the gem and it turned into a bit of dependency hell and eventually looked as though I'd have to upgrade to rails 4 (which I don't particularly want to do right now) in order to get this fix.

所以我想我第一次尝试了猴子补丁,并在初始化文件夹中创建了一个.rd,其中包含对更改的添加以添加sqlserver 2014支持:

So I thought I make my first attempt at a monkey patch and created an .rd in my initializers folder that incorporates the the changes to add sqlserver 2014 support:

module ConnectionAdapters  

    class SqlServerAdapter < AbstractAdapter
      SUPPORTED_VERSIONS = [2005,2008,2010,2011,2012,2014]


      # === SQLServer Specific (DB Reflection) ======================== #

       def sqlserver_2014?
        @database_year == 2014
      end



    end
   end

我的意图是通过更改github上的修复程序来简单地覆盖sqlserver_adapter.rd中的几行代码.但是,当我尝试部署时,我现在遇到一个引用AbstractAdapter的UnitializedConstant错误.

My intention was to simply override the several lines of code in sqlserver_adapter.rd with change in the fix on github. However when I try to deploy, I now get an UnitializedConstant Error referring to AbstractAdapter.

如何使此修补程序起作用?还是有更好的方法来完成此任务?

How can make this patch work? Or this there a better way to accomplish this task?

推荐答案

我找到了比猴子补丁更好的解决方案.原来,activeactive-sqlserver-adapter的家伙更新了各个发行版,因此我只需要指定具有SQLServer 2014支持修补程序的3.2分支即可.我的gem文件中的以下行解决了整个问题,我们现在连接到SqlServer '14

I found a much better solution than a monkey patch. Turns out the guys over at activerecord-sqlserver-adapter updated the various releases so I just had to specify the version 3.2 branch with the SQLServer 2014 support fix. The following line in my gem file resolved the entire issue and we are now connecting to SqlServer '14

gem 'activerecord-sqlserver-adapter', :git => "git://github.com/rails-sqlserver/activerecord-sqlserver-adapter.git", :branch => "3-2-stable" 

这篇关于将SQL 2014支持添加到activerecord-sqlserver-adapter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆