Giter VIP home page Giter VIP logo

do's Introduction

DataObjects README

DataObjects.rb is an attempt to rewrite existing Ruby database drivers to conform to one, standard interface.

At present the following drivers are available:

Database Vendor MRI (1.8.6/7) / 1.9 JRuby
MySQL x x
Oracle x x
PostgreSQL x x
SQLite3 x x
Derby - x
H2 - x
HSQLDB - x
SQL Server pending x
OpenEdge - x

There is experimental support for Rubinius.

More drivers are currently under development. If you feel like living on the edge, install and test drivers directly from this repository.

Introduction

To connect to and query the database, DataObjects relies on native extensions. Native extensions have been written in both C (for Ruby 1.8.6/7 (MRI), Ruby 1.9.x (YARV) and Rubinius platform) and Java (for the JRuby platform). Individual drivers may include extensions for both Ruby MRI and JRuby, or one or the other.

C extensions have been written using according to each vendor API. Java drivers use the standard JDBC API. Although there are dialectical differences between the Java drivers, the JDBC API ensures a reasonable amount of commonality. As such, the Java extensions rely on a common do_jdbc gem, which wraps code that is common to all of the Java extensions.

Installation

To install a driver from the repository cd into the driver directory and use the provided rake install task to install for the default platform.

Copyright and Licensing

Please see the copyright notices in each individual driver README.markdown or LICENSE file. Java-based drivers bundle JDBC driver JAR files, which may be provided under a license that is more restrictive than the MIT License used by the data_objects gem itself.

do's People

Contributors

abevoelker avatar ashgti avatar bauerpauer avatar benburkert avatar bernerdschaefer avatar brandondrew avatar cbandy avatar cjheath avatar ckoenig avatar cypher avatar david avatar dbussink avatar dkubb avatar hryk avatar jpr5 avatar jwkoelewijn avatar lostfly avatar luislavena avatar michaelklishin avatar mkristian avatar myabc avatar namelessjon avatar pbrant avatar postmodern avatar protocarl avatar rsim avatar sam avatar tpitale avatar wycats avatar xaviershay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

do's Issues

unable to reference the gems using git path

I have a Gemfile:

source :gemcutter

git 'git://github.com/datamapper/do.git' do
gem 'do_jdbc'
end

Running bundle install, I got:

$ bundle install
Using addressable (2.2.7)
Using data_objects (0.10.8)
Using do_jdbc (0.10.8) from git://github.com/datamapper/do.git (at master)
do_jdbc at /Users/pcheng/.rvm/gems/jruby-1.6.6@gemset/bundler/gems/do-8a539150a617/do_jdbc did not have a valid gemspec.
This prevents bundler from installing bins or native extensions, but that may not affect its functionality.
The validation message from Rubygems was:
["lib/do_jdbc_internal.jar"] are not files

Using bundler (1.0.22)

Connection/Authentication is increadibly slow under JRuby

I was testing code that would test for weak Database passwords using DataObjects. Under CRuby DataObjects was incredibly fast, able to open/authenticate/close connections almost instantly. Under JRuby, there appears to be a ~5 second delay after a failed authentication. This delay seems to increase with each authentication failure. I'm not sure if this is due to the Java Extensions or to JDBC.

Example Code: https://gist.github.com/1381544

LoadError: dlopen

Hi, I have a Sinatra app that gives me this error:

Boot Error

Something went wrong while loading app.rb

LoadError: dlopen(/Users/chip/.rvm/gems/ruby-1.8.7-p352/gems/do_sqlite3-0.10.6/lib/do_sqlite3/do_sqlite3.bundle, 9): Symbol not found: _sqlite3_enable_load_extension Referenced from: /Users/chip/.rvm/gems/ruby-1.8.7-p352/gems/do_sqlite3-0.10.6/lib/do_sqlite3/do_sqlite3.bundle Expected in: flat namespace in /Users/chip/.rvm/gems/ruby-1.8.7-p352/gems/do_sqlite3-0.10.6/lib/do_sqlite3/do_sqlite3.bundle - /Users/chip/.rvm/gems/ruby-1.8.7-p352/gems/do_sqlite3-0.10.6/lib/do_sqlite3/do_sqlite3.bundle

/Users/chip/.rvm/gems/ruby-1.8.7-p352/gems/do_sqlite3-0.10.6/lib/do_sqlite3/do_sqlite3.bundle
/Users/chip/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
/Users/chip/.rvm/gems/ruby-1.8.7-p352/gems/do_sqlite3-0.10.6/lib/do_sqlite3.rb:27
/Users/chip/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
/Users/chip/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
/Users/chip/.rvm/gems/ruby-1.8.7-p352/gems/dm-sqlite-adapter-1.1.0/lib/dm-sqlite-adapter/adapter.rb:1
/Users/chip/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
/Users/chip/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
/Users/chip/.rvm/gems/ruby-1.8.7-p352/gems/dm-sqlite-adapter-1.1.0/lib/dm-sqlite-adapter.rb:1
/Users/chip/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:59:in `gem_original_require'
/Users/chip/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:59:in `require'
/Users/chip/.rvm/gems/ruby-1.8.7-p352/gems/dm-core-1.1.0/lib/dm-core/adapters.rb:163:in `load_adapter'
/Users/chip/.rvm/gems/ruby-1.8.7-p352/gems/dm-core-1.1.0/lib/dm-core/adapters.rb:133:in `adapter_class'
/Users/chip/.rvm/gems/ruby-1.8.7-p352/gems/dm-core-1.1.0/lib/dm-core/adapters.rb:13:in `new'
/Users/chip/.rvm/gems/ruby-1.8.7-p352/gems/dm-core-1.1.0/lib/dm-core.rb:219:in `setup'
/Users/chip/code/fitness/app.rb:6
/Users/chip/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
/Users/chip/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
/Users/chip/.rvm/gems/ruby-1.8.7-p352/gems/shotgun-0.9/lib/shotgun/loader.rb:114:in `inner_app'
/Users/chip/.rvm/gems/ruby-1.8.7-p352/gems/shotgun-0.9/lib/shotgun/loader.rb:102:in `assemble_app'
/Users/chip/.rvm/gems/ruby-1.8.7-p352/gems/shotgun-0.9/lib/shotgun/loader.rb:86:in `proceed_as_child'
/Users/chip/.rvm/gems/ruby-1.8.7-p352/gems/shotgun-0.9/lib/shotgun/loader.rb:31:in `call!'
/Users/chip/.rvm/gems/ruby-1.8.7-p352/gems/shotgun-0.9/lib/shotgun/loader.rb:18:in `call'
/Users/chip/.rvm/gems/ruby-1.8.7-p352/gems/shotgun-0.9/lib/shotgun/favicon.rb:12:in `call'
/Users/chip/.rvm/gems/ruby-1.8.7-p352/gems/rack-1.3.6/lib/rack/builder.rb:134:in `call'
/Users/chip/.rvm/gems/ruby-1.8.7-p352/gems/rack-1.3.6/lib/rack/handler/webrick.rb:59:in `service'
/Users/chip/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/Users/chip/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/Users/chip/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/Users/chip/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:162:in `start'
/Users/chip/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/Users/chip/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:95:in `start'
/Users/chip/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:92:in `each'
/Users/chip/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:92:in `start'
/Users/chip/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:23:in `start'
/Users/chip/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:82:in `start'
/Users/chip/.rvm/gems/ruby-1.8.7-p352/gems/rack-1.3.6/lib/rack/handler/webrick.rb:13:in `run'
/Users/chip/.rvm/gems/ruby-1.8.7-p352/gems/shotgun-0.9/bin/shotgun:156
/Users/chip/.rvm/gems/ruby-1.8.7-p352/bin/shotgun:19:in `load'
/Users/chip/.rvm/gems/ruby-1.8.7-p352/bin/shotgun:19

I'm running RVM 1.8.5, Ruby 1.8.7-p352 on OSX 10.7.2. I googled for LoadError, _sqlite3_enable_load_extension, and a number of other things related to do_sqlite3 and haven't found anything useful yet.

Do you have a suggestion? Thanks.

do_postgres does work with rubyinstaller version 2.1

the do_postgres gem does not work under ruby 2.1.x when running under the ruby installer on windows 7. Installation succeeds, but when I try and use it, it fails to load. primarily because the gems\do_postgres-0.10.14-x86-mingw32\lib\do_postgres\2.1\do_postgres.so file seems to be missing. The gem works correctly under ruby 2.0. My guess is because there is a lib/2.0/do_postgres.so available.

I'm using ruby installer, 32 bit, on windows 7.

Any help would be appreciated.

jdbc-postgres jar never gets loaded from do_postgres in JRuby

As the title says, the jar from jdbc-postgres is never loaded in do_postgres.

The file is loaded through require, but the subsequent java_import will always fail, because Jdbc::Postgres::load_driver never gets called. jdbc-postgres provides the module with the method to load it, but it is not used. Thus using do_postgres under JRuby will cause errors about not finding org.postgres.Driver from the java_import.

A simple case of:

DataMapper.setup :default, {
:adapter => 'postgres',
:host => 'localhost',
:database => 'GenesisDevelopment',
:user => 'postgres',
}

under JRuby will cause this issue.

quoting.rb: no implicit conversion from nil to integer

My entities are defined as such.

I issue a query like this:

author = Author.first(:name.like => "%Knuth%")

And I get this error, which I've traced down to this line. I really don't understand it all. I've tried commenting out some of the surrounding code, thinking that the error was actually occurring on the line above line 12. I've added logging to the quote_string method that's being called on line 12 -- the problem's not there, as it doesn't even make it that far. So, something is going on in the case-when statement.

sql: SELECT `id`, `name` FROM `authors` WHERE `name` LIKE ? ORDER BY `id` LIMIT ? var: %Knuth%
 ~ no implicit conversion from nil to integer
/home3/jrm425/usr/lib/ruby/gems/1.9.1/gems/data_objects-0.10.3/lib/data_objects/quoting.rb:12:in `quote_string': no implicit conversion from nil to integer (TypeError)
        from /home3/jrm425/usr/lib/ruby/gems/1.9.1/gems/data_objects-0.10.3/lib/data_objects/quoting.rb:12:in `quote_value'
        from /home3/jrm425/usr/lib/ruby/gems/1.9.1/gems/data_objects-0.10.3/lib/data_objects/command.rb:69:in `block in escape_sql'
        from /home3/jrm425/usr/lib/ruby/gems/1.9.1/gems/data_objects-0.10.3/lib/data_objects/command.rb:61:in `gsub!'
        from /home3/jrm425/usr/lib/ruby/gems/1.9.1/gems/data_objects-0.10.3/lib/data_objects/command.rb:61:in `escape_sql'
        from /home3/jrm425/usr/lib/ruby/gems/1.9.1/gems/dm-do-adapter-1.1.0/lib/dm-do-adapter/adapter.rb:147:in `execute_reader'
        from /home3/jrm425/usr/lib/ruby/gems/1.9.1/gems/dm-do-adapter-1.1.0/lib/dm-do-adapter/adapter.rb:147:in `block in read'
        from /home3/jrm425/usr/lib/ruby/gems/1.9.1/gems/dm-do-adapter-1.1.0/lib/dm-do-adapter/adapter.rb:276:in `with_connection'
        from /home3/jrm425/usr/lib/ruby/gems/1.9.1/gems/dm-do-adapter-1.1.0/lib/dm-do-adapter/adapter.rb:141:in `read'
        from /home3/jrm425/usr/lib/ruby/gems/1.9.1/gems/dm-core-1.1.0/lib/dm-core/repository.rb:162:in `read'
        from /home3/jrm425/usr/lib/ruby/gems/1.9.1/gems/dm-core-1.1.0/lib/dm-core/model.rb:370:in `first'
        from test.rb:10:in `<main>'

UPDATE: The problem is still on line 12 of quoting.rb, however I've noticed that something weird is going on with the call to quote_string. I made an exact copy of this method called myquotestring and replaced the call to quote_string with an equivalent call to my new method and things worked fine. There's obviously some meta-programming magic going on somewhere that I'm not aware of.

do_sqlite3:0.10.14 - LoadError: "cannot load such file -- do_sqlite3/2.1/do_sqlite3"

Environment:
RubyInstaller 2.1.5
do_sqlite3:0.10.14

Stack trace:

D:/programs/development/ruby-2.1.4-x64-mingw32/lib/ruby/gems/2.1.0/gems/do_sqlite3-0.10.6-x86-mingw32/lib/do_sqlite3.rb:31:in require': cannot load such file -- do_sqlite3/2.1/do_sqlite3 (LoadError) from D:/programs/development/ruby-2.1.4-x64-mingw32/lib/ruby/gems/2.1.0/gems/do_sqlite3-0.10.6-x86-mingw32/lib/do_sqlite3.rb:31:inrescue in <top (required)>'
from D:/programs/development/ruby-2.1.4-x64-mingw32/lib/ruby/gems/2.1.0/gems/do_sqlite3-0.10.6-x86-mingw32/lib/do_sqlite3.rb:26:in <top (required)>' from D:/programs/development/ruby-2.1.4-x64-mingw32/lib/ruby/gems/2.1.0/gems/dm-sqlite-adapter-1.2.0/lib/dm-sqlite-adapter/adapter.rb:1:inrequire'
from D:/programs/development/ruby-2.1.4-x64-mingw32/lib/ruby/gems/2.1.0/gems/dm-sqlite-adapter-1.2.0/lib/dm-sqlite-adapter/adapter.rb:1:in <top (required)>' from D:/programs/development/ruby-2.1.4-x64-mingw32/lib/ruby/gems/2.1.0/gems/dm-sqlite-adapter-1.2.0/lib/dm-sqlite-adapter.rb:1:inrequire'
from D:/programs/development/ruby-2.1.4-x64-mingw32/lib/ruby/gems/2.1.0/gems/dm-sqlite-adapter-1.2.0/lib/dm-sqlite-adapter.rb:1:in <top (required)>' from D:/programs/development/ruby-2.1.4-x64-mingw32/lib/ruby/gems/2.1.0/gems/bundler-1.7.10/lib/bundler/runtime.rb:76:inrequire'
from D:/programs/development/ruby-2.1.4-x64-mingw32/lib/ruby/gems/2.1.0/gems/bundler-1.7.10/lib/bundler/runtime.rb:76:in block (2 levels) in require' from D:/programs/development/ruby-2.1.4-x64-mingw32/lib/ruby/gems/2.1.0/gems/bundler-1.7.10/lib/bundler/runtime.rb:72:ineach'
from D:/programs/development/ruby-2.1.4-x64-mingw32/lib/ruby/gems/2.1.0/gems/bundler-1.7.10/lib/bundler/runtime.rb:72:in block in require' from D:/programs/development/ruby-2.1.4-x64-mingw32/lib/ruby/gems/2.1.0/gems/bundler-1.7.10/lib/bundler/runtime.rb:61:ineach'
from D:/programs/development/ruby-2.1.4-x64-mingw32/lib/ruby/gems/2.1.0/gems/bundler-1.7.10/lib/bundler/runtime.rb:61:in require' from D:/programs/development/ruby-2.1.4-x64-mingw32/lib/ruby/gems/2.1.0/gems/bundler-1.7.10/lib/bundler.rb:134:inrequire'
from D:/work/workspace/passtor/config/boot.rb:8:in <top (required)>' from D:/programs/development/ruby-2.1.4-x64-mingw32/lib/ruby/gems/2.1.0/gems/padrino-core-0.12.4/lib/padrino-core/cli/launcher.rb:25:inrequire'
from D:/programs/development/ruby-2.1.4-x64-mingw32/lib/ruby/gems/2.1.0/gems/padrino-core-0.12.4/lib/padrino-core/cli/launcher.rb:25:in start' from D:/programs/development/ruby-2.1.4-x64-mingw32/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:inrun'
from D:/programs/development/ruby-2.1.4-x64-mingw32/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in invoke_command' from D:/programs/development/ruby-2.1.4-x64-mingw32/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:indispatch'
from D:/programs/development/ruby-2.1.4-x64-mingw32/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:in start' from D:/programs/development/ruby-2.1.4-x64-mingw32/lib/ruby/gems/2.1.0/gems/padrino-core-0.12.4/bin/padrino:9:in<top (required)>'
from D:/programs/development/ruby-2.1.4-x64-mingw32/bin/padrino:23:in load' from D:/programs/development/ruby-2.1.4-x64-mingw32/bin/padrino:23:in

'

Possible to compile do_postgres with only libpq?

Hello,

I'm trying to build binaries for libpq, the supposed to be client library of postgres that is small enough to be used on non-postgres installations.

Problem is that do_postgres depends on postgres.h headers that are not present when only using libpq interface.

It is possible change do_postgres to only use libpq interface option?

Thank you.

Case sensitive error message test

See: https://github.com/datamapper/do/blob/master/do_jdbc/src/main/java/data_objects/Command.java#L324

In the above code the system checks if the error message is equal to "query does not return results". I'm seeing errors in DM's specs because the error is now being returned as "Query does not return results".

Locally I made the following change:

diff --git a/do_jdbc/src/main/java/data_objects/Command.java b/do_jdbc/src/main/java/data_objects/Command.java
index 6edac92..70be2bc 100644
--- a/do_jdbc/src/main/java/data_objects/Command.java
+++ b/do_jdbc/src/main/java/data_objects/Command.java
@@ -321,7 +321,7 @@ public class Command extends DORubyObject {
         } catch (SQLException sqle) {
             // XXX sqlite3 jdbc driver happily throws an exception if the result set is empty :P
             // this sets up a minimal empty reader
-            if (sqle.getMessage().equals("query does not return results")) {
+            if (sqle.getMessage().toLowerCase().equals("query does not return results")) {

                 // pass the response to the Reader
                 reader.resultSet = resultSet;

And it seemed to resolve the problem I was seeing in the specs.

If there's no problem with this kind of fix I can submit a PR with this change.

unanable install do_sqlite3 on osx 10.8.3

gem -v
2.0.3
rake, version 10.0.4
ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]

mkdir -p .gem.20130411-19080-1tg0iyk/do_sqlite3
/usr/bin/install -c -m 0755 do_sqlite3.bundle ./.gem.20130411-19080-1tg0iyk/do_sqlite3
Exception Errno::ENOENT' at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/fileutils.rb:1209 - No such file or directory - /Library/Ruby/Gems/1.8/gems/do_sqlite3-0.10.12/lib/do_sqlite3/do_sqlite3.bundle ExceptionErrno::ENOENT' at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/fileutils.rb:1209 - No such file or directory - ./.gem.20130411-19080-1tg0iyk/do_sqlite3/do_sqlite3.bundle
Exception NoMethodError' at /Library/Ruby/Site/1.8/rubygems/installer.rb:681 - undefined methodjoin' for nil:NilClass
Exception NoMethodError' at /Library/Ruby/Site/1.8/rubygems/installer.rb:684 - undefined methodjoin' for nil:NilClass
ERROR: While executing gem ... (NoMethodError)
undefined method join' for nil:NilClass /Library/Ruby/Site/1.8/rubygems/installer.rb:684:inbuild_extensions'
/Library/Ruby/Site/1.8/rubygems/installer.rb:652:in each' /Library/Ruby/Site/1.8/rubygems/installer.rb:652:inbuild_extensions'
/Library/Ruby/Site/1.8/rubygems/installer.rb:218:in install' /Library/Ruby/Site/1.8/rubygems/dependency_installer.rb:372:ininstall'
/Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:45:in each_with_index' /Library/Ruby/Site/1.8/rubygems/dependency_installer.rb:332:ineach'
/Library/Ruby/Site/1.8/rubygems/dependency_installer.rb:332:in each_with_index' /Library/Ruby/Site/1.8/rubygems/dependency_installer.rb:332:ininstall'
/Library/Ruby/Site/1.8/rubygems/commands/install_command.rb:166:in execute' /Library/Ruby/Site/1.8/rubygems/commands/install_command.rb:158:ineach'
/Library/Ruby/Site/1.8/rubygems/commands/install_command.rb:158:in execute' /Library/Ruby/Site/1.8/rubygems/command.rb:305:ininvoke_with_build_args'
/Library/Ruby/Site/1.8/rubygems/command_manager.rb:170:in process_args' /Library/Ruby/Site/1.8/rubygems/command_manager.rb:130:inrun'
/Library/Ruby/Site/1.8/rubygems/gem_runner.rb:60:in `run'
/usr/bin/gem:21
removing ./siteconf20130411-19080-oyafp-0.rb...done

DataObjects::ConnectionError when loading both dm-mysql-adapter and dm-sqlite-adapter gems

dkubb asked to make this ticket on irc and of course I didn't read that he wanted it to github, not lighthouse. Sorry about the duplicate http://datamapper.lighthouseapp.com/projects/20609-datamapper/tickets/1512-dataobjectsconnectionerror-when-loading-both-dm-mysql-adapter-and-dm-sqlite-adapter-gems

I have in my Gemfile both dm-mysql-adapter and dm-sqlite-adapter. First for prod/dev and sqlite for speedy tests. I load them using bundler and now when I run tests even though I specifically setup with DataMapper.setup(:default, "sqlite::memory:") it tries to connect somewhere else using some default rules with root@localhost. My code runs after I comment out the dm-mysql from Gemfile.

Gemfile has

gem 'datamapper', '1.1.0'
gem 'dm-mysql-adapter', '1.1.0'
gem 'dm-sqlite-adapter', '1.1.0'

I setup them with

Bundler.setup
DataMapper.setup(:default, "sqlite::memory:")

Expected behaviour

Datamapper would connect to in memory sqlite database

What really happens

DataObjects::ConnectionError: Access denied for user 'root'@'localhost' (using password: NO)

Backtrace

DataObjects::ConnectionError: Access denied for user 'root'@'localhost' (using password: NO)
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/data_objects-0.10.5/lib/data_objects/connection.rb:79:in `initialize'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/data_objects-0.10.5/lib/data_objects/connection.rb:79:in `new'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/data_objects-0.10.5/lib/data_objects/pooling.rb:177:in `block in new'
<internal:prelude>:10:in `synchronize'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/data_objects-0.10.5/lib/data_objects/pooling.rb:172:in `new'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/data_objects-0.10.5/lib/data_objects/pooling.rb:119:in `new'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/data_objects-0.10.5/lib/data_objects/connection.rb:68:in `new'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-do-adapter-1.1.0/lib/dm-do-adapter/adapter.rb:251:in `open_connection'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-transactions-1.1.0/lib/dm-transactions/adapters/dm-do-adapter.rb:69:in `open_connection'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-do-adapter-1.1.0/lib/dm-do-adapter/adapter.rb:276:in `with_connection'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-do-adapter-1.1.0/lib/dm-do-adapter/adapter.rb:33:in `select'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-migrations-1.1.0/lib/dm-migrations/adapters/dm-sqlite-adapter.rb:43:in `table_info'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-migrations-1.1.0/lib/dm-migrations/adapters/dm-sqlite-adapter.rb:18:in `storage_exists?'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-migrations-1.1.0/lib/dm-migrations/auto_migration.rb:63:in `storage_exists?'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-migrations-1.1.0/lib/dm-migrations/auto_migration.rb:118:in `storage_exists?'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-constraints-1.1.0/lib/dm-constraints/migrations.rb:36:in `auto_migrate_down_constraints!'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-migrations-1.1.0/lib/dm-migrations/auto_migration.rb:45:in `block in repository_execute'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-core-1.1.0/lib/dm-core/support/descendant_set.rb:66:in `block in each'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-core-1.1.0/lib/dm-core/support/subject_set.rb:212:in `block in each'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-core-1.1.0/lib/dm-core/support/ordered_set.rb:321:in `block in each'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-core-1.1.0/lib/dm-core/support/ordered_set.rb:321:in `each'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-core-1.1.0/lib/dm-core/support/ordered_set.rb:321:in `each'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-core-1.1.0/lib/dm-core/support/subject_set.rb:212:in `each'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-core-1.1.0/lib/dm-core/support/descendant_set.rb:65:in `each'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-migrations-1.1.0/lib/dm-migrations/auto_migration.rb:44:in `repository_execute'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-constraints-1.1.0/lib/dm-constraints/migrations.rb:10:in `auto_migrate!'
spec/models/account_spec.rb:8:in `block (2 levels) in <top (required)>

DataObjects::Command#escape_sql is broken

This method takes an array of arguments and attempts to interpolate the arguments into the stored sql string (@text) using a regular expression and gsub. It attempts to do this even if no arguments are given, which can break valid queries even if no arguments are used. There are other problems:

  1. It assumes that ? is the placeholder character. However, on PostgreSQL, ? is a valid operator character, and is used for some hstore operators. You can't execute queries with hstore operators using DataObjects, since it assumes the ? is a placeholder.
  2. Parsing SQL via regular expressions is broken and should never be done. The only way to reliably parse SQL is to do it via the database's libraries. Even for the same database, the parsing rules can differ depending on configuration. For example, on PostgreSQL, ''?'' could be either the string '?' or the expression '' ? '' (two strings with \ with the ? operator between them) depending on the standard_conforming_strings setting.

This method and the code that uses it probably needs to be redesigned so that it doesn't attempt to parse SQL. As a stop gap measure until that can be done, the method should just return the stored sql string without any changes if the args argument is empty.

Symbol conflict with the sqlite3 gem

Hi,

do_sqlite3 seems to use the same symbol name as the sqlite3 gem. In particular, we're both using mSqlite3. If you do:

require "do_sqlite3"
require "sqlite3"

There is a collision, since both libraries are using the same symbol. I was wondering if you would consider changing the symbol you're using as to not conflict? Here is the ticket on the sqlite3 side.

If changing seems like too much trouble, we can do it on the sqlite3 side, but I wanted to start a conversation.

Thanks! :D

Query Execution is broken in do_mysql 0.10.5

I cannot seem to be able to perform auto_migrations or selections using do_mysql 0.10.5.

Asn.auto_migrate!
 ~   SQL (0.253ms)  DROP TABLE IF EXISTS `asns`
 ~   SQL (0.008ms)  SHOW TABLES LIKE 'asns'
 ~ near "SHOW": syntax error (code: 1, sql state: , query: SHOW TABLES LIKE 'asns'

User.first
 ~   SQL (0.171ms)  SELECT `id`, /*REDACTED*/ FROM `users` ORDER BY `id` LIMIT 1
 ~ no such table: users (code: 1, sql state: , query: SELECT `id`, /*REDACTED*/ FROM `users` ORDER BY `id` LIMIT 1, 

Downgrading back to data_objects 0.10.3 and do_mysql 0.10.3 fixed the problem.

Segmentation fault in data_objects on new hosting (Nginx+Passenger)

I've just tried moving my Sinatra app to new hosting. The environment:

  • "Passenger 3.0.11 (nginx 1.0.10/Ruby 1.9.3)".
  • ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-linux]
  • CentOS release 6.4 (Final)

DataMapper seems to access the database okay. (If I deliberately use a bad password then I get an error message saying MySQL denied access to the user.) And I can define my models, but the first time I try to access any data in the DB (e.g. by MyModel.count) I get a segmentation fault.

/home/myuser/webapps/myapp/gems/gems/data_objects-0.10.12/lib/data_objects/connection.rb:79: [BUG] Segmentation fault

Does this look like data_object's problem? (Sorry if that's a dumb question. I haven't encountered a segmentation fault in Ruby before.) What other information would be useful for me to supply here?

This app works on my previous hosting and on my laptop but I'm using Thin rather than Passenger on those systems.

default date/time doesn't work properly in postgres

DataMapper.setup(:default, 'postgres://localhost/bug')

class Bug
  include DataMapper::Resource

  property :id, Serial
  property :date_added, Date, :required => true,
                              :default => DateTime.now
end

DataMapper.finalize

creates this:

bug=# \d bugs;
                           Table "public.bugs"
   Column   |  Type   |                     Modifiers                     
------------+---------+---------------------------------------------------
 id         | integer | not null default nextval('bugs_id_seq'::regclass)
 date_added | date    | not null default '2011-09-11'::date
Indexes:
    "bugs_pkey" PRIMARY KEY, btree (id)

...the actual date/time is set correctly when creating records but this schema will not play nicely with apps that interact with the database through some other method.

can't install do_sqlite3 on windows

C:\Documents and Settings\Dominic E Sisneros>ruby -v
ruby 1.9.3p429 (2013-05-15) [i386-mingw32]

C:\Documents and Settings\Dominic E Sisneros>gem install do_sqlite3
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing do_sqlite3:
ERROR: Failed to build gem native extension.

C:/pw_working/ruby/Ruby193/bin/ruby.exe extconf.rb

checking for sqlite3.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/pw_working/ruby/Ruby193/bin/ruby
--with-sqlite3-dir
--without-sqlite3-dir
--with-sqlite3-include
--without-sqlite3-include=${sqlite3-dir}/include
--with-sqlite3-lib
--without-sqlite3-lib=${sqlite3-dir}/lib

Gem files will remain installed in C:/pw_working/ruby/Ruby193/lib/ruby/gems/1.9.1/gems/do_sqlite3-0.10.13 for inspection.
Results logged to C:/pw_working/ruby/Ruby193/lib/ruby/gems/1.9.1/gems/do_sqlite3-0.10.13/ext/do_sqlite3/gem_make.out

C:\Documents and Settings\Dominic E Sisneros>more c:\pw_working\ruby\Ruby193\lib\ruby\gems\1.9.1\gems\do_sqlite3-0.10.13\ext\do_sqlite3\mkmf.log
have_header: checking for sqlite3.h... -------------------- no

"gcc -o conftest -IC:/pw_working/ruby/Ruby193/include/ruby-1.9.1/i386-mingw32 -IC:/pw_working/ruby/Ruby193/include/ruby-1.9.1/ruby/backward -IC:/pw_working/ru
by/Ruby193/include/ruby-1.9.1 -I. -I/usr/local/include -I/opt/local/include -I/usr/include -DFD_SETSIZE=2048 -DFD_SETSIZE=2048 -O3 -fno-omit-frame-pointer -
g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-stat
ement -Wimplicit-function-declaration -Wall -DHAVE_NO_DATETIME_NEWBANG conftest.c -L. -LC:/pw_working/ruby/Ruby193/lib -L/usr/local/lib -L/opt/local/lib -L/
usr/lib -L. -lmsvcrt-ruby191 -lshell32 -lws2_32 -limagehlp -lshlwapi "
checked program was:
/* begin _/
1: #include "ruby.h"
2:
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char *_argv)
6: {
7: return 0;
8: }
/* end */

"gcc -E -IC:/pw_working/ruby/Ruby193/include/ruby-1.9.1/i386-mingw32 -IC:/pw_working/ruby/Ruby193/include/ruby-1.9.1/ruby/backward -IC:/pw_working/ruby/Ruby19
3/include/ruby-1.9.1 -I. -I/usr/local/include -I/opt/local/include -I/usr/include -DFD_SETSIZE=2048 -DFD_SETSIZE=2048 -O3 -fno-omit-frame-pointer -g -Wall -
Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wi
mplicit-function-declaration -Wall -DHAVE_NO_DATETIME_NEWBANG conftest.c -o conftest.i"
conftest.c:5:21: fatal error: sqlite3.h: No such file or directory
compilation terminated.
checked program was:
/* begin /
1: #include "ruby.h"
2:
3: #include <winsock2.h>
4: #include <windows.h>
5: #include <sqlite3.h>
/
end */


Exposing busy_timeout to sqlite3 API

Using datamapper and do_sqlite3 with multiple programs writing to the same db is impossible. The writes often fail with BusyError. I can work around it by using a different db, or hacking datamapper source to sleep/retry writes.

sqlite3 db engine has a built in 'retry on busy' function that fixes this problem:
http://www.sqlite.org/c3ref/busy_timeout.html

do_sqlite3 does not expose this API. What do you think of using this in do_sqlite3?

There are several ways to do it:

  • set 'retry on busy' on every sqlite3 connection opened. The only side effect would be that people that were getting BusyError before would get slowdown in performance instead.
  • allow developers to set the flag in the URI using query arguments (sqlite3://dev.sqlite?busy_retry=200

PS: I would not use this setup in production, but it is useful for development. Love the simplicity of sqlite3 setup.

postgres - precision lost when casting on double precision

I have a table that is using a type of double precision. I am trying to perform a round(cast(column as numeric),2). When I perform this in psql I get the correct results. So 17.1799913573964 becomes 17.18. When I am using the datamapper postgre driver I get the value 0.1718E2. Any thoughts on this. Here is the psql query.

select id, round(cast(distance as numeric),2) miles, distance from (SELECT id, ( 3959 * acos( cos( radians(42.0926245) ) *cos( radians( lat ) ) * cos( radians( lng ) - radians(-88.1152973) ) + sin( radians(42.0926245) ) * sin(radians( lat ) ) ) ) AS distance FROM operator_positions ) position where distance < 20

PostgreSQL adapter does not correctly quote bytea values

When trying to pass a value for a bytea field, that includes an ASCII backlash, DataObjects does not correctly escape the input.

conn.create_command("CREATE TABLE bob (salt bytea)").execute_non_query
conn.create_command("INSERT INTO bob (salt) VALUES (?)").execute_non_query("FJ\\")
ERROR:  invalid input syntax for type bytea (DataObjects::DataError)
LINE 1: INSERT INTO users (password_salt) VALUES ('FJ\')
                                                  ^

The backslashes need to be double-escaped for bytea casts to work. See http://www.postgresql.org/docs/8.1/static/datatype-binary.html

do_sqlite3 segfaults when trying to load extensions

On MRI 1.9.3

require 'dm-core'

DataMapper.setup(:default, 'sqlite3::memory:')

repository.adapter.send(:with_connection ) {|c| c.extension.load_extension("...")}

Backtrace:

/tmp/test.rb:20: [BUG] Segmentation fault
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0030 p:---- s:0109 b:0109 l:000108 d:000108 CFUNC  :load_extension
c:0029 p:0019 s:0105 b:0105 l:000096 d:000104 BLOCK  /tmp/test.rb:20
c:0028 p:0017 s:0102 b:0102 l:000101 d:000101 METHOD /home/asher/.rvm/gems/ruby-1.9.3-p0/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:276
c:0027 p:0055 s:0097 b:0097 l:000096 d:000096 TOP    /tmp/test.rb:20
c:0026 p:---- s:0095 b:0095 l:000094 d:000094 FINISH
c:0025 p:---- s:0093 b:0093 l:000092 d:000092 CFUNC  :require
c:0024 p:0053 s:0089 b:0089 l:000088 d:000088 METHOD /home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36
c:0023 p:0011 s:0082 b:0082 l:0014b8 d:000081 EVAL   (irb):1
c:0022 p:---- s:0080 b:0080 l:000079 d:000079 FINISH
c:0021 p:---- s:0078 b:0078 l:000077 d:000077 CFUNC  :eval
c:0020 p:0028 s:0071 b:0071 l:000070 d:000070 METHOD /home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb/workspace.rb:80
c:0019 p:0033 s:0064 b:0063 l:000062 d:000062 METHOD /home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb/context.rb:254
c:0018 p:0031 s:0058 b:0058 l:002688 d:000057 BLOCK  /home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb.rb:159
c:0017 p:0042 s:0050 b:0050 l:000049 d:000049 METHOD /home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb.rb:273
c:0016 p:0011 s:0045 b:0045 l:002688 d:000044 BLOCK  /home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb.rb:156
c:0015 p:0144 s:0041 b:0041 l:000024 d:000040 BLOCK  /home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb/ruby-lex.rb:243
c:0014 p:---- s:0038 b:0038 l:000037 d:000037 FINISH
c:0013 p:---- s:0036 b:0036 l:000035 d:000035 CFUNC  :loop
c:0012 p:0009 s:0033 b:0033 l:000024 d:000032 BLOCK  /home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb/ruby-lex.rb:229
c:0011 p:---- s:0031 b:0031 l:000030 d:000030 FINISH
c:0010 p:---- s:0029 b:0029 l:000028 d:000028 CFUNC  :catch
c:0009 p:0023 s:0025 b:0025 l:000024 d:000024 METHOD /home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb/ruby-lex.rb:228
c:0008 p:0046 s:0022 b:0022 l:002688 d:002688 METHOD /home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb.rb:155
c:0007 p:0011 s:0019 b:0019 l:0010d8 d:000018 BLOCK  /home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb.rb:70
c:0006 p:---- s:0017 b:0017 l:000016 d:000016 FINISH
c:0005 p:---- s:0015 b:0015 l:000014 d:000014 CFUNC  :catch
c:0004 p:0183 s:0011 b:0011 l:0010d8 d:0010d8 METHOD /home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb.rb:69
c:0003 p:0142 s:0006 b:0006 l:000958 d:0006d8 EVAL   /home/asher/.rvm/rubies/ruby-1.9.3-p0/bin/irb:16
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:000958 d:000958 TOP   

-- Ruby level backtrace information ----------------------------------------
/home/asher/.rvm/rubies/ruby-1.9.3-p0/bin/irb:16:in `<main>'
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb.rb:69:in `start'
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb.rb:69:in `catch'
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb.rb:70:in `block in start'
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb.rb:155:in `eval_input'
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `each_top_level_statement'
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `catch'
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `block in each_top_level_statement'
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `loop'
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb/ruby-lex.rb:243:in `block (2 levels) in each_top_level_statement'
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb.rb:156:in `block in eval_input'
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb.rb:273:in `signal_status'
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb.rb:159:in `block (2 levels) in eval_input'
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb/context.rb:254:in `evaluate'
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb/workspace.rb:80:in `evaluate'
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb/workspace.rb:80:in `eval'
(irb):1:in `irb_binding'
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/tmp/test.rb:20:in `<top (required)>'
/home/asher/.rvm/gems/ruby-1.9.3-p0/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:276:in `with_connection'
/tmp/test.rb:20:in `block in <top (required)>'
/tmp/test.rb:20:in `load_extension'

-- C level backtrace information -------------------------------------------
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x17bf2a) [0x7fec04fe8f2a] vm_dump.c:796
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x5f487) [0x7fec04ecc487] error.c:258
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(rb_bug+0xb7) [0x7fec04ecd217] error.c:277
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x110d9f) [0x7fec04f7dd9f] signal.c:609
/lib/libpthread.so.0(+0xf270) [0x7fec04c60270]
/usr/lib/libsqlite3.so.0(+0x17761) [0x7fec00dc1761]
/usr/lib/libsqlite3.so.0(+0x246a5) [0x7fec00dce6a5]
/usr/lib/libsqlite3.so.0(+0x2ab38) [0x7fec00dd4b38]
/usr/lib/libsqlite3.so.0(+0x2ad89) [0x7fec00dd4d89]
/usr/lib/libsqlite3.so.0(sqlite3_load_extension+0xce) [0x7fec00de7dbe]
/home/asher/.rvm/gems/ruby-1.9.3-p0/gems/do_sqlite3-0.10.8/lib/do_sqlite3/do_sqlite3.so(do_sqlite3_cExtension_load_extension+0x7f) [0x7fec010522ff] do_sqlite3_extension.c:66
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x175761) [0x7fec04fe2761] vm_insnhelper.c:404
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x16b539) [0x7fec04fd8539] insns.def:1015
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x171a3a) [0x7fec04fdea3a] vm.c:1220
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(rb_iseq_eval+0x1f0) [0x7fec04fe4660] vm.c:1447
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x681b3) [0x7fec04ed51b3] load.c:310
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(rb_require_safe+0x5af) [0x7fec04ed661f] load.c:619
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x175761) [0x7fec04fe2761] vm_insnhelper.c:404
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x16b539) [0x7fec04fd8539] insns.def:1015
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x171a3a) [0x7fec04fdea3a] vm.c:1220
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x171ea5) [0x7fec04fdeea5] vm_eval.c:1030
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x17234f) [0x7fec04fdf34f] vm_eval.c:1071
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x175761) [0x7fec04fe2761] vm_insnhelper.c:404
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x16b539) [0x7fec04fd8539] insns.def:1015
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x171a3a) [0x7fec04fdea3a] vm.c:1220
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x17607f) [0x7fec04fe307f] vm.c:624
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(rb_rescue2+0x16b) [0x7fec04ed30bb] eval.c:639
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x16744e) [0x7fec04fd444e] vm_eval.c:826
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x175761) [0x7fec04fe2761] vm_insnhelper.c:404
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x16b539) [0x7fec04fd8539] insns.def:1015
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x171a3a) [0x7fec04fdea3a] vm.c:1220
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x17675e) [0x7fec04fe375e] vm.c:654
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(rb_catch_obj+0xbe) [0x7fec04fd612e] vm_eval.c:1534
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x1691de) [0x7fec04fd61de] vm_eval.c:1510
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x175761) [0x7fec04fe2761] vm_insnhelper.c:404
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x16b539) [0x7fec04fd8539] insns.def:1015
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x171a3a) [0x7fec04fdea3a] vm.c:1220
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x17675e) [0x7fec04fe375e] vm.c:654
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(rb_catch_obj+0xbe) [0x7fec04fd612e] vm_eval.c:1534
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x1691de) [0x7fec04fd61de] vm_eval.c:1510
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x175761) [0x7fec04fe2761] vm_insnhelper.c:404
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x16b539) [0x7fec04fd8539] insns.def:1015
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x171a3a) [0x7fec04fdea3a] vm.c:1220
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(rb_iseq_eval_main+0xaf) [0x7fec04fe475f] vm.c:1461
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x64e92) [0x7fec04ed1e92] eval.c:204
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(ruby_exec_node+0x1d) [0x7fec04ed2c4d] eval.c:251
/home/asher/.rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(ruby_run_node+0x1e) [0x7fec04ed4bfe] eval.c:244
irb() [0x40089b]
/lib/libc.so.6(__libc_start_main+0xed) [0x7fec03f9a38d]
irb() [0x4008c9]

do_postgres halts execution when running through Net::SSH::Gateway

On ruby 1.9.3p286, I think that the thread keeping the connection event loop open here: https://github.com/net-ssh/net-ssh-gateway/blob/master/lib/net/ssh/gateway.rb#L195 is preventing DO from connecting to a postgres database over that gateway. Putting the connection in another thread has no effect.

I suspect that this is do to the lack of real threading in ruby, even with 1.9.3's improvements. The reason I think this is because if I attempt to make the connection in a fork process everything works as expected.

On the other hand, Net::SSH and regular ruby continue to proceed inside the gateway due to the use of Thread.pass. So I'm still, I'm not sure why DO would simply stop execution. The process simply halts, no warnings, no errors, no timeout, it doesn't ever stop. Even hitting control-c doesn't kill the process. I have to ctrl-z and kill -9 the pid.

Can anyone confirm my suspicion or offer a hint as to what might be going on?

Time is losing timezone from DB and assuming local time zone

For columns that are timestamp with zone … and DataMapper properties that are Time, the time zone is assumed to be local by the autocasting done in do_postgres (I haven't checked other drivers). This ignores the actual time zone for the data in that column.

DataObjects' pool size is 8. It really should be configurable.

This was originally reported against the dm-core project by @kapso, I figured I'd open up the issue here since I can't seem to find one already.

It's understandable why the pool size is always 8, but I really think that should be configurable :)

I'm experimenting with a monkey-patch cited in this StackOverflow post, which is roughly

DB_POOL_SIZE = 12

class DataObjects::Pooling::Pool
  alias :initialize_old :initialize
  def initialize(max_size, resource, args)
    initialize_old(DB_POOLSIZE, resource, args)
  end
end

I figure if this is more configurable, then dm-core can support configuring it, and help me avoid this whole monkey-patching business

"DataObjects::Mysql::Command [...] in parallel should finish within 2 seconds" test failing on Debian FreeBSD/Hurd

Hi!

Datamapper tests are enabled when building datamapper-mysql packages for Debian. They pass perfectly, except on the Freebsd and Hurd architecture, when one test fails:
The trace below is for Freebsd. The same test fails with Hurd (The number there is slightly above 4 seconds).

I see in the source that this particular test is marked as pending for Windows. Maybe it needs to be marked as pending for a larger class of OS containing also Freebsd and Hurd?

1) DataObjects::Mysql::Command it should behave like a Command with async running queries in parallel should finish within 2 seconds
     Failure/Error: Unable to find matching line from backtrace
       expected: < 2
            got:   2.008432
     Shared Example Group: "a Command with async" called from 
     # /usr/lib/ruby/vendor_ruby/rspec/expectations/fail_with.rb:32:in `fail_with'
     # /usr/lib/ruby/vendor_ruby/rspec/matchers/operator_matcher.rb:47:in `fail_with_message'
     # /usr/lib/ruby/vendor_ruby/rspec/matchers/operator_matcher.rb:71:in `__delegate_operator'
     # /usr/lib/ruby/vendor_ruby/rspec/matchers/operator_matcher.rb:59:in `eval_match'
     # /usr/lib/ruby/vendor_ruby/rspec/matchers/operator_matcher.rb:28:in `<'
     # /usr/lib/ruby/vendor_ruby/data_objects/spec/shared/command_spec.rb:228
     # /usr/lib/ruby/vendor_ruby/data_objects/spec/lib/pending_helpers.rb:7:in `pending_if'
     # /usr/lib/ruby/vendor_ruby/data_objects/spec/shared/command_spec.rb:227
     # /usr/lib/ruby/vendor_ruby/rspec/core/example.rb:80:in `instance_eval'
     # /usr/lib/ruby/vendor_ruby/rspec/core/example.rb:80:in `run'
     # /usr/lib/ruby/vendor_ruby/rspec/core/example.rb:173:in `with_around_hooks'
     # /usr/lib/ruby/vendor_ruby/rspec/core/example.rb:77:in `run'
     # /usr/lib/ruby/vendor_ruby/rspec/core/example_group.rb:355:in `run_examples'
     # /usr/lib/ruby/vendor_ruby/rspec/core/example_group.rb:351:in `map'
     # /usr/lib/ruby/vendor_ruby/rspec/core/example_group.rb:351:in `run_examples'
     # /usr/lib/ruby/vendor_ruby/rspec/core/example_group.rb:337:in `run'
     # /usr/lib/ruby/vendor_ruby/rspec/core/example_group.rb:338:in `run'
     # /usr/lib/ruby/vendor_ruby/rspec/core/example_group.rb:338:in `map'
     # /usr/lib/ruby/vendor_ruby/rspec/core/example_group.rb:338:in `run'
     # /usr/lib/ruby/vendor_ruby/rspec/core/example_group.rb:338:in `run'
     # /usr/lib/ruby/vendor_ruby/rspec/core/example_group.rb:338:in `map'
     # /usr/lib/ruby/vendor_ruby/rspec/core/example_group.rb:338:in `run'
     # /usr/lib/ruby/vendor_ruby/rspec/core/command_line.rb:28:in `run'
     # /usr/lib/ruby/vendor_ruby/rspec/core/command_line.rb:28:in `map'
     # /usr/lib/ruby/vendor_ruby/rspec/core/command_line.rb:28:in `run'
     # /usr/lib/ruby/vendor_ruby/rspec/core/reporter.rb:34:in `report'
     # /usr/lib/ruby/vendor_ruby/rspec/core/command_line.rb:25:in `run'
     # /usr/lib/ruby/vendor_ruby/rspec/core/runner.rb:80:in `run_in_process'
     # /usr/lib/ruby/vendor_ruby/rspec/core/runner.rb:69:in `run'
     # /usr/lib/ruby/vendor_ruby/rspec/core/runner.rb:10:in `autorun'
     # /usr/bin/rspec:4

Finished in 4.89 seconds
71 examples, 1 failure

Thanks,

Cédric

Field-count mismatch error in do_mysql

Recently I'm seeing more errors like "ArgumentError: Field-count mismatch. Expected 6 fields, but the query yielded 0" and it roughly corresponds with the upgrade to 0.10.13.

I think the change made in b7ba9a8 causes an invalid number of fields to be returned and for the error in https://github.com/datamapper/do/blob/master/do_mysql/ext/do_mysql/do_mysql.c#L528 to be raised.

I don't know what the valid fix would be. It doesn't seem to actually be caused by an invalid query being sent to the driver.. all of these queries are the ones generated by DataMapper.

DataObjects logs database password on database error

When there's a database exception thrown DO includes the database password in the logs. Example:

 DM: ERROR:  duplicate key value violates unique constraint "tsu_pkey"
DETAIL:  Key (tsu_id)=(.) already exists. (code: 83906754, sql state: 23505, query: INSERT INTO "tsu" ("sc_id", "psu_id", "tsu_id", "tsu_name") VALUES ('200000XX', '200000XX', '.', '.'), uri: postgres:mdes_warehouse:ACTUAL_PASSWORD@server:5432mdes_warehouse_working?username=mdes_warehouse&database=mdes_warehouse_working&adapter=postgres&host=server&port=5432&password=ACTUAL_PASSWORD)

I'm seeing this with DO 0.10.7 and do_postgres 0.10.7. I'm using DO within DataMapper 1.2.0. I mentioned this issue on the datamapper mailing list and it was suggested that it's a DO bug.

Incorrect post installation log on windows

I've installated do_sqlite3 with native extension on windows 7 x86_64

After the installation i see this message in console

Post-install message from do_sqlite3:

You've installed the binary version of do_sqlite3.
It was built using Sqlite3 version 3071300.
It's recommended to use the exact same version to avoid potential issues.

At the time of building this gem, the necessary DLL files where available
in the following download:

http://www.sqlite.org/sqlitedll-3071300.zip

You can put the sqlite3.dll available in this package in your Ruby bin
directory, for example C:\Ruby\bin

That's ok, i go to the link, but it doesn't exist. The correct url is: http://www.sqlite.org/sqlite-dll-win32-x86-3071300.zip

Cannot build do_postgres anymore with jruby 1.7.0 and latest bundler:

When I do jruby -S rake --trace install I get

rake aborted!
Unable to determine name from existing gemspec. Use :name => 'gemname' in #install_tasks to manually set it.
/opt/arch/jruby/jruby-1.7.0/lib/ruby/gems/shared/gems/bundler-1.2.1/lib/bundler/gem_helper.rb:30:in `initialize'
/opt/arch/jruby/jruby-1.7.0/lib/ruby/gems/shared/gems/bundler-1.2.1/lib/bundler/gem_helper.rb:14:in `install_tasks'
/opt/arch/jruby/jruby-1.7.0/lib/ruby/gems/shared/gems/do_postgres-0.10.10/Rakefile:5:in `(root)'
org/jruby/RubyKernel.java:1045:in `load'
/opt/arch/jruby/jruby-1.7.0/lib/ruby/gems/shared/gems/rake-0.9.2.2/lib/rake/rake_module.rb:1:in `(root)'
/opt/arch/jruby/jruby-1.7.0/lib/ruby/gems/shared/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/opt/arch/jruby/jruby-1.7.0/lib/ruby/gems/shared/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile'
/opt/arch/jruby/jruby-1.7.0/lib/ruby/gems/shared/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `load_rakefile'
/opt/arch/jruby/jruby-1.7.0/lib/ruby/gems/shared/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/opt/arch/jruby/jruby-1.7.0/lib/ruby/gems/shared/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
/opt/arch/jruby/jruby-1.7.0/lib/ruby/gems/shared/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `run'
/opt/arch/jruby/jruby-1.7.0/lib/ruby/gems/shared/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/opt/arch/jruby/jruby-1.7.0/lib/ruby/gems/shared/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
org/jruby/RubyKernel.java:1045:in `load'
/opt/arch/jruby/jruby-1.7.0/bin/rake:23:in `(root)'

Using a plain gem install command on the gem tries to compile the native extension, so that's no solution. What to do?

missing do_jdbc_internal.jar

Then installing for jruby/java, gem is missing the file do_jdbc_internal.jar.

This causes do_jdbc-0.10.0-java to fail with jruby

do_sqlite3 not loading

I am seeing:

cannot load such file -- do_sqlite3/do_sqlite3

do_sqlite3 (0.10.12)
dm-sqlite-adapter (1.2.0)
dm-core (1.2.0)
ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-linux]

Installing do_postgres fails on OSX maverick and brew install postgresql

I am running postgresql 9.3 on OSX Maverick. I think they changed the include location for postgres.h so the build fails. I was able to get it installed by specifying options as follows.

gem install do_postgres -- --with-pgsql-server-dir=/usr/local/Celler/postgresql/9.3.5_1 --with-pgsql-server-include=/usr/local/Cellar/postgresql/9.3.5_1/include/server

Unable to compile do_oracle.c with Ruby 2.0.0-p0

Able to compile properly when using Ruby 1.9.3. Tested with patch levels 327 and 392. Unable to compile using Ruby 2.0.0

compiling do_oracle.c
do_oracle.c: In function ‘data_objects_debug’:
do_oracle.c:123: warning: ISO C90 forbids mixed declarations and code
do_oracle.c:125: warning: implicit conversion shortens 64-bit value into a 32-bit value
do_oracle.c: In function ‘cDO_OracleCommand_execute_internal’:
do_oracle.c:393: warning: ISO C90 forbids mixed declarations and code
do_oracle.c: In function ‘cDO_OracleCommand_execute_try’:
do_oracle.c:415: error: expected ‘(’ before ‘!’ token
do_oracle.c:415: warning: statement with no effect
do_oracle.c:415: error: expected ‘;’ before ‘{’ token
do_oracle.c:412: warning: unused variable ‘insert_id_present’
do_oracle.c: In function ‘cDO_OracleConnection_initialize’:
do_oracle.c:464: warning: initialization discards qualifiers from pointer target type
do_oracle.c:464: warning: initialization discards qualifiers from pointer target type
do_oracle.c:508: warning: passing argument 2 of ‘get_uri_option’ discards qualifiers from pointer target type
do_oracle.c:519: warning: passing argument 2 of ‘get_uri_option’ discards qualifiers from pointer target type
do_oracle.c: In function ‘cDO_OracleCommand_execute_non_query’:
do_oracle.c:547: warning: ISO C90 forbids mixed declarations and code
do_oracle.c: In function ‘cDO_OracleReader_next’:
do_oracle.c:636: warning: ISO C90 forbids mixed declarations and code
make: *** [do_oracle.o] Error 1

Strange LoadError on Windows

Hi, i'm using DataMapper with Postgresql on Windows XP for development. Ruby 1.9.3 with RubyInstaller. The setup is normal, there is no error in loading gems.
But when i run the same setup on Windows Server 2008 machine, do_postgres can't be loaded. The error is here:

E:/dungth/Ruby193/lib/ruby/gems/1.9.1/gems/do_postgres-0.10.12-x86-mingw32/lib/d
o_postgres.rb:31:in `require': 126: The specified module could not be found.   -
 E:/dungth/Ruby193/lib/ruby/gems/1.9.1/gems/do_postgres-0.10.12-x86-mingw32/lib/
do_postgres/1.9/do_postgres.so (LoadError)
        from E:/dungth/Ruby193/lib/ruby/gems/1.9.1/gems/do_postgres-0.10.12-x86-
mingw32/lib/do_postgres.rb:31:in `rescue in <top (required)>'
        from E:/dungth/Ruby193/lib/ruby/gems/1.9.1/gems/do_postgres-0.10.12-x86-
mingw32/lib/do_postgres.rb:26:in `<top (required)>'
        from E:/dungth/Ruby193/lib/ruby/gems/1.9.1/gems/dm-postgres-adapter-1.2.
0/lib/dm-postgres-adapter/adapter.rb:1:in `require'
        from E:/dungth/Ruby193/lib/ruby/gems/1.9.1/gems/dm-postgres-adapter-1.2.
0/lib/dm-postgres-adapter/adapter.rb:1:in `<top (required)>'
        from E:/dungth/Ruby193/lib/ruby/gems/1.9.1/gems/dm-postgres-adapter-1.2.
0/lib/dm-postgres-adapter.rb:1:in `require'
        from E:/dungth/Ruby193/lib/ruby/gems/1.9.1/gems/dm-postgres-adapter-1.2.
0/lib/dm-postgres-adapter.rb:1:in `<top (required)>'
        from E:/dungth/Ruby193/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-cor
e/adapters.rb:163:in `require'
        from E:/dungth/Ruby193/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-cor
e/adapters.rb:163:in `load_adapter'
        from E:/dungth/Ruby193/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-cor
e/adapters.rb:133:in `adapter_class'
        from E:/dungth/Ruby193/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-cor
e/adapters.rb:13:in `new'
        from E:/dungth/Ruby193/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-cor
e.rb:230:in `setup'

Do you know why is this error and how to fix it ?
Thank you very much.

do_mysql should not automatically coerce tinyint(1) values into bools

When executing a select against a MySQL table with tinyint(1) columns both the C extension and the Java extension will coerce a tinyint(1) field into a type of TrueClass

TINYINT can be (unsigned) between 0 and 255, which is agreat many more values than True/False :)

FWIW, this issue was encountered when trying to use DataMapper's "group by" support (e.g. Person.all(:fields => [:job], :unique => true, :order => [:job.asc])) over a dm-types Enum property

do_postgres won't install with postgresql-9.3 on Ubuntu 13.10

I can't seem to get do_postgres to install on ubuntu 13.10 with postgresql-9.3. I install postgresql and the dev libraries:

$ sudo apt-get install postgresql-9.3 libpq-dev

But when I try to install the do_postgres I get the following error:

$ gem install do_postgres
Building native extensions.  This could take a while...
ERROR:  Error installing do_postgres:
    ERROR: Failed to build gem native extension.

    /home/martin/.rbenv/versions/2.1.0/bin/ruby extconf.rb
checking for main() in -lpq... yes
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for postgres.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/home/martin/.rbenv/versions/2.1.0/bin/ruby
    --with-pgsql-server-dir
    --without-pgsql-server-dir
    --with-pgsql-server-include
    --without-pgsql-server-include=${pgsql-server-dir}/include
    --with-pgsql-server-lib
    --without-pgsql-server-lib=${pgsql-server-dir}/lib
    --with-pgsql-client-dir
    --without-pgsql-client-dir
    --with-pgsql-client-include
    --without-pgsql-client-include=${pgsql-client-dir}/include
    --with-pgsql-client-lib
    --without-pgsql-client-lib=${pgsql-client-dir}/lib
    --with-pqlib
    --without-pqlib
Could not find PostgreSQL build environment (libraries & headers): Makefile not created

extconf failed, exit code 1

Gem files will remain installed in /home/martin/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/do_postgres-0.10.14 for inspection.
Results logged to /home/martin/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/extensions/x86_64-linux/2.1.0-static/do_postgres-0.10.14/gem_make.out

The pg installs fine, it just seems to be do_postgres

do_postgres needs ssl options support

I'm currently using dm/do to connect to a postgresql server with ssl enabled with enforced client certificates.

After scouring the internet and finding the mysql ssl settings in the wiki (https://github.com/datamapper/do/wiki/MySQL), it seems that no such options exist for do_postgres.

Luckily, the low level driver will still happily use ENV variables set in ruby, but passing these in the hash (or on the url like connection string) would be ideal.

For the sake of reference:

Here's a sample pgsql command like from 9.2 with the newer style connection string options:

psql "sslmode=verify-ca user=myuser hostaddr=10.10.10.40 dbname=mydb sslcert=/srv/postgresql/client.crt sslkey=/srv/postgresql/client.key sslrootcert=/srv/postgresql/ca.crt"

Here are the relevant ENV/connection string variables for SSL connections from http://www.postgresql.org/docs/9.2/static/libpq-envars.html:

  • PGSSLMODE behaves the same as the sslmode connection parameter.
  • PGSSLCOMPRESSION behaves the same as the sslcompression connection parameter.
  • PGSSLCERT behaves the same as the sslcert connection parameter.
  • PGSSLKEY behaves the same as the sslkey connection parameter.
  • PGSSLROOTCERT behaves the same as the sslrootcert connection parameter.
  • PGSSLCRL behaves the same as the sslcrl connection parameter.

DataObjects error when using two repositories

I have this simple code using two sqlite stores:

require "data_mapper"

class Foo
    include DataMapper::Resource

    property :id, Serial
    property :name, String
end

DataMapper.finalize

DataMapper.setup(:default, "sqlite:foo.sqlite")
DataMapper.setup(:lite, "sqlite:foo2.sqlite")

DataMapper.repository(:default).auto_migrate!
DataMapper.repository(:lite).auto_migrate!

# :default repo
Foo.create(:name => "foo")

# :lite repo
DataMapper.repository(:lite) { Foo.create(:name => "bar") }

Default repository works, but Lite repository throws this error:

/usr/lib/ruby/gems/1.9.1/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:114:in `execute_non_query': no such table: foos (DataObjects::SyntaxError)
    from /usr/lib/ruby/gems/1.9.1/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:114:in `block (2 levels) in create'
    from /usr/lib/ruby/gems/1.9.1/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:276:in `with_connection'
    from /usr/lib/ruby/gems/1.9.1/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:113:in `block in create'
    from /usr/lib/ruby/gems/1.9.1/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:85:in `each'
    from /usr/lib/ruby/gems/1.9.1/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:85:in `create'
    from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/repository.rb:146:in `create'
    from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/resource/persistence_state/transient.rb:61:in `create_resource'
    from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/resource/persistence_state/transient.rb:25:in `commit'
    from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/resource.rb:956:in `_persist'
    from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/resource.rb:970:in `block in create_with_hooks'
    from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/resource.rb:967:in `catch'
    from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/resource.rb:967:in `create_with_hooks'
    from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/resource.rb:1021:in `save_self'
    from /usr/lib/ruby/gems/1.9.1/gems/dm-validations-1.2.0/lib/dm-validations.rb:54:in `save_self'
    from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/resource.rb:1006:in `block in _save'
    from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/resource.rb:1222:in `run_once'
    from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/resource.rb:1005:in `_save'
    from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/resource.rb:405:in `save'
    from /usr/lib/ruby/gems/1.9.1/gems/dm-validations-1.2.0/lib/dm-validations.rb:40:in `block in save'
    from /usr/lib/ruby/gems/1.9.1/gems/dm-validations-1.2.0/lib/dm-validations/context.rb:16:in `in_context'
    from /usr/lib/ruby/gems/1.9.1/gems/dm-validations-1.2.0/lib/dm-validations.rb:40:in `save'
    from /usr/lib/ruby/gems/1.9.1/gems/dm-validations-1.2.0/lib/dm-validations.rb:130:in `create'
    from foo.rb:22:in `block in <main>'
    from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core.rb:263:in `block in repository'
    from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/repository.rb:114:in `scope'
    from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core.rb:263:in `repository'
    from foo.rb:22:in `<main>'

Is this a bug?

I'm using recently updated gems:

data_objects (0.10.7)
datamapper (1.2.0)
dm-aggregates (1.2.0)
dm-constraints (1.2.0)
dm-core (1.2.0)
dm-do-adapter (1.2.0)
dm-migrations (1.2.0)
dm-mysql-adapter (1.2.0)
dm-serializer (1.2.1)
dm-sqlite-adapter (1.2.0)
dm-timestamps (1.2.0)
dm-transactions (1.2.0)
dm-types (1.2.1)
dm-validations (1.2.0)
do_mysql (0.10.7)
do_sqlite3 (0.10.7)

and my ruby version:

ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.