labrador icon indicating copy to clipboard operation
labrador copied to clipboard

Support for MSSQL

Open hrp opened this issue 12 years ago • 9 comments

I would like to add support for MS SQL Server via the tiny_tds gem. What would be necessary to add another adapter?

hrp avatar Feb 02 '13 22:02 hrp

Figured it out. Wasn't too bad.

hrp avatar Feb 02 '13 23:02 hrp

I would love to see this as pull request. So long as tiny_tds builds on non MS SQL platforms there should be no reason we can't get this in. I'm sure as you have already figured out, a new adapter needs only respond to these methods:

def collections
end

def find(collection_name, options = {})
end

def create(collection_name, data = {})
end

def update(collection_name, id, data = {})
end

def delete(collection_name, id)
end

def primary_key_for(collection_name)
end

def connected?
end

def close
end

def id
end

def name
end

def schema(collection)
end

def as_json(options = nil)
end

I need to improve the documentation on the method signatures/return values and add a guide to the readme on this.

chrismccord avatar Feb 03 '13 23:02 chrismccord

Cool. I have it more or less working. What's the format that schema should return?

hrp avatar Feb 04 '13 05:02 hrp

#schema just returns the result of the database query as a hash similar to the #find method. ie, the mysql adapter simply returns the result of session.query("DESCRIBE #{collection_name}") as a hash. Also, use any of the sql adapter unit tests as a template for the new adapter tests. The assertions should be more or less equivalent. I'm really looking forward to this. Thanks!

chrismccord avatar Feb 04 '13 13:02 chrismccord

Heads up: tiny_tds will build on unix, but requires FreeTDS.

hrp avatar Feb 05 '13 06:02 hrp

I saw that FreeTDS was required. Do you know if we can automate the free-tds build process? A quick glance at the MiniPortile section of of tiny_tds suggests it may be possible. Automation is required so we can maintain the "copy/paste" install process from http://chrismccord.github.com/labrador/

If we can't automate the build process, I would still like to get this in at least on a mssql branch that we can rebase and keep current with master, as well as provide additional documentation for. MSSQL support would be great to have for those who need it. Let me know what you think.

chrismccord avatar Feb 05 '13 14:02 chrismccord

Found a good way to test: Amazon RDS has a free tier (http://aws.amazon.com/rds/pricing/sqlserver/).

hrp avatar Feb 25 '13 04:02 hrp

So I have a tested branch now: https://github.com/hrp/labrador/tree/mssql. Next, I want to implement a way to easily run stored procedures.

The final step would be figuring out how to maintain the simple install process. The MiniPortile approach would work but instead of doing that on the user's machine (requires a checkout of the tiny_tds source) we could create a fork of tiny_tds that comes with FreeTDS and include that gem in this project.

I also wonder if MSSQL support should be an optional add-on.

hrp avatar Feb 28 '13 17:02 hrp

I like the optional add-on approach if we aren't able to get an automated build processes that isn't as simple as bundle install. You mentioned forking tiny_ds and including FreeTDS, would this be something that would allow a simple gem custom_tiny_tds ? If so, I would like to experiment with that approach. At minimum, we could have MYSSQL as an optional add-on from an mssql branch that we keep up to date with master and add special documentation for, so it is at least there for those who require it. My only hesitation with merging with master if we can automate the install is requiring a remote instance for testing, although that's a decent trade off. Let me think about that one. Thanks for your work so far. Browsing the branch looks like the code + tests are perfect.

chrismccord avatar Mar 03 '13 22:03 chrismccord