Skip to content
This repository has been archived by the owner on Sep 27, 2022. It is now read-only.

Added postgreSQL support. #6

Closed
wants to merge 2 commits into from
Closed

Conversation

fdegiuli
Copy link

@fdegiuli fdegiuli commented Jun 4, 2013

Backticks are unsupported in postgres, which broke the bulk_update.... method.

This checks for a postgres adapter and adjusts the query accordingly.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling dd3c2b2 on fdegiuli:postgres-support into e605a0b on mezis:master.

@mezis
Copy link
Owner

mezis commented Jun 20, 2013

Hi there! Sorry I missed this. PostgreSQL compatibility was added by #3 and released with v0.2.2.
It's tested on Travis, too (as well as with MySQL).

Could you point me to what doesn't work for you?

@fdegiuli
Copy link
Author

The backticks in the query for the bulk_update_fuzzy_[name] method aren't
supported in PostgreSQL. There are some interesting syntax error messages.
I just made a quick change that removes them if the db adapter being used
is a PostgresAdapter.

Cheers,

On Thu, Jun 20, 2013 at 7:06 AM, Julien Letessier
notifications@github.comwrote:

Hi there! Sorry I missed this. PostgreSQL compatibility was added by #3https://github.com/mezis/fuzzily/issues/3and released with v0.2.2.
It's tested on Travis, too (as well as with MySQL).

Could you point me to what doesn't work for you?


Reply to this email directly or view it on GitHubhttps://github.com//pull/6#issuecomment-19754859
.

@bclennox
Copy link

bclennox commented Jul 9, 2013

👍

We also ran into the same problem with the back ticks in Postgres. FWIW, I changed my Gemfile to point to @fdegiuli's repo and we were able to run bulk_update_fuzzy_* again.

@mezis
Copy link
Owner

mezis commented Jul 13, 2013

@bclennox I'll take care of this today. I didn't merge @fdegiuli's pull request directly as I want to avoid ifs and maintaining SQL for every engine out there, but I guess I might have to :)

mezis added a commit that referenced this pull request Jul 13, 2013
mezis added a commit that referenced this pull request Jul 13, 2013
@bclennox
Copy link

You should be able to use quote_table_name and related methods to escape those values instead of having to worry about database adapters. I haven't tried it with this code specifically, but it seems like it would be straightforward.

@mezis
Copy link
Owner

mezis commented Jul 13, 2013

@bclennox doing so as we speak. I wanted to avoid it, but it turns out some versions of SQlite require the quotes while others don't.

@mezis
Copy link
Owner

mezis commented Jul 13, 2013

Crapola. The fix works perfectly with all 3 engines locally, but fails with SQLite on Travis:

     Failure/Error: subject.bulk_update_fuzzy_name
     ActiveRecord::StatementInvalid:
       SQLite3::SQLException: near ",": syntax error: 
                   INSERT INTO "trigrams" ("owner_type", "owner_id", "fuzzy_field", "score", "trigram")
                   VALUES
                 ('Stuff',1,'name',5,'**p'), ('Stuff',1,'name',5,'*pa'), ('Stuff',1,'name',5,'par'), ('Stuff',1,'name',5,'ari'), ('Stuff',1,'name',5,'ris'), ('Stuff',1,'name',5,'is*')

(i.e. the quoting fails, in all versions of activerecord). I'll keep digging after lunch, but clues are welcome :)

@mezis
Copy link
Owner

mezis commented Jul 13, 2013

Follow-up—Travis probably uses an old version of SQLite, older than 3.7.11 where bulk inserts were added. I'll find a workaround.
(which means I simply uncovered another bug!)

@mezis
Copy link
Owner

mezis commented Jul 13, 2013

Just released version 0.2.3 to adress these issues.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants