Skip to content
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

Does friendly_id work with sql server as the backend for rails ? #214

Closed
amitagit opened this issue Jan 17, 2012 · 5 comments
Closed

Does friendly_id work with sql server as the backend for rails ? #214

amitagit opened this issue Jan 17, 2012 · 5 comments

Comments

@amitagit
Copy link

Is there some configuration change needed to make friendly_id work with sql server and tiny_tds?

I am using friendly_id 4.0.0 rails 3.0.1 and tiny_tds 0.2.3 (because I have a sql server database as a backend for the rails application)

This stackoverflow query has the details:
http://stackoverflow.com/questions/8875135/friendly-id-does-not-work-with-sql-server-and-tiny-tds

I am getting the following error while trying to create a new record from console:
ActiveRecord::StatementInvalid: TinyTds::Error: 'LENGTH' is not a recognized built-in function name

This is because SQL Server does not have the LENGTH function, but is has a LEN function.

So the query on line 48 in slug_generator.rb is causing the problem.

Also the find_each(&:save) does not update the slug for existing records even if I change the line in slug_generator.rb to make it LEN instead of LENGTH. However making this change in slug_generator.rb successfully creates a new record with the slug from rails console.

@norman
Copy link
Owner

norman commented Jan 17, 2012

No, SQL Server isn't supported, but only because I lack the required licenses, time and knowledge. If somebody were willing to help me implement and, most importantly, maintain compatibility, then I'd be more than happy to support it.

@CraigStuntz
Copy link

I'm afraid I don't have time to spend on this (I don't use this project, and came here via a Stack Overflow question) but I'll point out that SQL Server Express is free and will be as good as any other edition for your purposes here, so licensing, at least, should not be an issue.

Having said that, I've browsed the source code a bit and I'm not sure you actually need "SQL Server support", per se. It seems to me that if you had an option like friendly_id_config.sql_length_function or the like which defaulted to LENGTH and use that in place of the hard-coded LENGTH in slug_generator.rb then a SQL Server user could simply change this option to LEN.

Hope that helps!

@norman
Copy link
Owner

norman commented Jan 24, 2012

Thanks for the info on the free license, I'll definitely check that out.

I think the solution you propose for the LEN issue is fine conceptually, and I'll implement something like that so that SQL Server isn't totally left out just because of a trivial incompatibility.

As far as real ongoing support for SQL Server, though - that is, keeping it in mind at all times like Postgres, MySQL and SQLite - I'd be very happy to accept an offer to help, but am not really willing to take on the responsibility myself unless some more people ask me for it.

@parndt
Copy link
Collaborator

parndt commented Mar 4, 2013

Does this issue need to be kept open?

@norman
Copy link
Owner

norman commented Apr 16, 2013

the LEN change is in master; closing.

@norman norman closed this as completed Apr 16, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants