nurettin / jruby-pg

A JRuby version of the "pg" gem.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DESCRIPTION:

This is a native implementation of the Postsgres protocol written entirely in Java. The project was started by @headius as a ruby-pg replacement for JRuby that uses the JDBC driver and private API of Postgres. Unfortunately ruby-pg (which uses libpq under the hood) exposed a lot of features of Postgres that were impossible to implement or were complicated given the nature of the JDBC and the encapsulation of many features that are exposed in ruby-pg.

WARNING this gem is not production ready yet. There are many bugs that needs to be fixed and more testing. So please checkout the code and submit pull requests with some fixes. If your Java-Fu isn’t that great you can still contribute by submitting test cases and We’ll be happy to fix them.

FEATURES:

  • A ruby-pg drop in replacement for JRuby

  • Async operations are supported

  • Large Object API

  • SSL connections

  • Copy operations

  • Zero dependencies on other jars and gems

  • All active record test suite pass (except 5 tests see PROBLEMS).

PROBLEMS:

  • Due to a bug in JRuby Array#delete (github.com/jruby/jruby/issues/411) you’ll need JRuby 1.7.1 or later.

  • Due to a bug in the json gem (github.com/flori/json/pull/152) and (github.com/flori/json/pull/155) you’ll need gem version 1.7.7 or later.

  • We currently have some failing tests when we run the activerecord test suite. The failing tests are due to the inconsistencies between JRuby and MRI (see github.com/jruby/jruby/issues/540 and github.com/jruby/jruby/pull/539)

  • The current implementation targets postgres protocol V3 (introduced in v 7.4) only. I’ll wait until someone ask for support of earlier versions.

  • Run pg_search test suites on this implementation

  • lo_import and lo_export are not implemented yet

  • More Documentation especially in the parts that deal with the protocol.

  • Profiling the library would be awesome, but will try to get it running first then optimize.

  • JRuby 1.6.x (1.8 mode) needs to be tested.

REQUIREMENTS:

  • Just a Postgres server and the gem.

INSTALL:

  • Currently we don’t have the gem on rubygems, but I’ll work on that if we can get a stable version out.

DEVELOPERS:

You’ll need postgres to be installed on your system. In order for you to be able to run rails test suite, you’ll also need the hstore extension which is also available in the postgresql-contrib Ubuntu package (see www.postgresql.org/docs/9.0/static/hstore.html for more info) and postgresql-server-dev to get the pg_config binary.

You’ll also need to create a new super user using your username and no password. You can use the following command to do that:

$ sudo -u postgres createuser -s <insert your username here>

You’ll also need to add the following line in the your pg_hba.conf (in order to disable password authentication):

host    all             <insert your username here>        127.0.0.1/32            trust

After checking out the source, run:

$ rake

This task will install any missing dependencies, run the tests/specs.

There are currently two test suites that run, the ruby-pg specs and more specs targetted towards the JRuby implementation details in jruby-spec. When you run ‘rake` both test suites are merged under the ’spec’ directory.

You can set PG_TEST_SLL to 1, e.g.

$ PG_TEST_SLL=1 rake

to run the entire test suite using SSL sockets instead of plain sockets. Also

$ test_all.sh

runs the test suite with and without SSL.

LICENSE:

(The MIT License)

Copyright © 2012 John V. Shahid and Charles Nutter.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

A JRuby version of the "pg" gem.


Languages

Language:Java 86.8%Language:Ruby 11.9%Language:Shell 1.4%