diogob / carrierwave-postgresql

Use PostgreSQL large objects (AKA BLOBs) to store your files inside the database
http://diogob.github.com/carrierwave-postgresql/
MIT License
56 stars 25 forks source link

JDBC Support #14

Closed TheKidCoder closed 8 years ago

TheKidCoder commented 10 years ago

Are there any plans to support the Postgres JDBC driver? I can give a stab at it, but would like to know first if anyone has tried it/planning on it.

diogob commented 10 years ago

Hello there, no plans for it. It has never been tried.

TheKidCoder commented 10 years ago

I actually created a fork that is working for me for the most part: https://github.com/TheKidCoder/carrierwave-postgresql

I am having issues with Java byte arrays, but seem to be almost done with it! Needs a lot of cleanup too, which I plan to do soon.

TheKidCoder commented 10 years ago

I wanted to open the dialog back up about Jruby support.

On my fork: https://github.com/TheKidCoder/carrierwave-postgresql

It is now 100% working and I kept the code as close to the PG gem as I could find.

The major difference between the MRI version and jRuby version is when you call uploader.read it returns a Java Byte Array. That is perfect for my needs, but may not be suitable for others.

What are your thoughts for providing both versions? Put both code bases in a single gem or separate?

nadavshatz commented 10 years ago

First off +1. Secondly, I would think that extracting the changes into two separate files and allowing for choice via a config value stating the platform would make the most sense.

Also - for consistency, it would be better to return the same type from "read".

Just as an FYI - I'm getting this warning: carrierwave/storage/postgresql_lo.rb:16 warning: ambiguous Java methods found, using open(long)

TheKidCoder commented 10 years ago

Thanks for the feedback.

I was able to fix the ambiguous warning. I also changed the return value from read to be a ruby string, the same as the MRI gem.

I'm thinking we can keep this in the same gem and just check for jruby and load the appropriate file if it is present.

Any feedback @diogob ?

diogob commented 10 years ago

@TheKidCoder considering the return type is the same I guess that we can do exactly as you've described. Separate in two different files, and load the appropriate one according to the ruby version being used. Will you be willing to work on it so we can integrate both?

diogob commented 10 years ago

@TheKidCoder looking at the code I thought that maybe just creating two different adapters for the connection operations might be enough, so the PostgresqlLo class can be exactly the same for both versions.

TheKidCoder commented 10 years ago

Thats a good idea, I'll get started on a pull request tomorrow.

TheKidCoder commented 8 years ago

@nadavshatz Just a heads up, JDBC has been merged in and is in v. 0.2.0.

Closing this.

nadavshatz commented 8 years ago

Thanks for the update @TheKidCoder :beers: