├── .gitignore ├── .travis.yml ├── Gemfile ├── MAVEN.markdown ├── README.markdown ├── Rakefile ├── TODO.markdown ├── data_objects ├── .autotest ├── .gitignore ├── .rspec ├── .yardopts ├── ChangeLog.markdown ├── Gemfile ├── LICENSE ├── README.markdown ├── Rakefile ├── data_objects.gemspec ├── lib │ ├── data_objects.rb │ └── data_objects │ │ ├── byte_array.rb │ │ ├── command.rb │ │ ├── connection.rb │ │ ├── error.rb │ │ ├── error │ │ ├── connection_error.rb │ │ ├── data_error.rb │ │ ├── integrity_error.rb │ │ ├── sql_error.rb │ │ ├── syntax_error.rb │ │ └── transaction_error.rb │ │ ├── ext │ │ ├── do_common.c │ │ └── do_common.h │ │ ├── extension.rb │ │ ├── logger.rb │ │ ├── pooling.rb │ │ ├── quoting.rb │ │ ├── reader.rb │ │ ├── result.rb │ │ ├── spec │ │ ├── lib │ │ │ ├── pending_helpers.rb │ │ │ ├── ssl.rb │ │ │ └── ssl_certs │ │ │ │ ├── ca-cert.pem │ │ │ │ ├── ca-key.pem │ │ │ │ ├── client-cert.pem │ │ │ │ ├── client-key.pem │ │ │ │ ├── client-req.pem │ │ │ │ ├── server-cert.pem │ │ │ │ ├── server-key.pem │ │ │ │ └── server-req.pem │ │ ├── setup.rb │ │ └── shared │ │ │ ├── command_spec.rb │ │ │ ├── connection_spec.rb │ │ │ ├── encoding_spec.rb │ │ │ ├── error │ │ │ └── sql_error_spec.rb │ │ │ ├── quoting_spec.rb │ │ │ ├── reader_spec.rb │ │ │ ├── result_spec.rb │ │ │ └── typecast │ │ │ ├── array_spec.rb │ │ │ ├── bigdecimal_spec.rb │ │ │ ├── boolean_spec.rb │ │ │ ├── byte_array_spec.rb │ │ │ ├── class_spec.rb │ │ │ ├── date_spec.rb │ │ │ ├── datetime_spec.rb │ │ │ ├── float_spec.rb │ │ │ ├── integer_spec.rb │ │ │ ├── ipaddr_spec.rb │ │ │ ├── nil_spec.rb │ │ │ ├── other_spec.rb │ │ │ ├── range_spec.rb │ │ │ ├── string_spec.rb │ │ │ └── time_spec.rb │ │ ├── transaction.rb │ │ ├── uri.rb │ │ ├── utilities.rb │ │ └── version.rb ├── spec │ ├── command_spec.rb │ ├── connection_spec.rb │ ├── do_mock.rb │ ├── do_mock2.rb │ ├── pooling_spec.rb │ ├── rcov.opts │ ├── reader_spec.rb │ ├── result_spec.rb │ ├── spec_helper.rb │ ├── transaction_spec.rb │ └── uri_spec.rb └── tasks │ ├── release.rake │ ├── spec.rake │ ├── yard.rake │ └── yardstick.rake ├── do_derby ├── .gitignore ├── .rspec ├── ChangeLog.markdown ├── Gemfile ├── LICENSE ├── README.markdown ├── Rakefile ├── buildfile ├── do_derby.gemspec ├── ext-java │ └── src │ │ └── main │ │ └── java │ │ └── do_derby │ │ ├── DerbyDriverDefinition.java │ │ └── DoDerbyService.java ├── lib │ ├── do_derby.rb │ └── do_derby │ │ └── version.rb ├── pom.xml ├── spec │ ├── command_spec.rb │ ├── connection_spec.rb │ ├── encoding_spec.rb │ ├── rcov.opts │ ├── reader_spec.rb │ ├── result_spec.rb │ ├── spec_helper.rb │ └── typecast │ │ ├── array_spec.rb │ │ ├── bigdecimal_spec.rb │ │ ├── boolean_spec.rb │ │ ├── byte_array_spec.rb │ │ ├── class_spec.rb │ │ ├── date_spec.rb │ │ ├── datetime_spec.rb │ │ ├── float_spec.rb │ │ ├── integer_spec.rb │ │ ├── nil_spec.rb │ │ ├── other_spec.rb │ │ ├── range_spec.rb │ │ ├── string_spec.rb │ │ └── time_spec.rb └── tasks │ ├── compile.rake │ ├── release.rake │ └── spec.rake ├── do_h2 ├── .gitignore ├── .rspec ├── ChangeLog.markdown ├── Gemfile ├── LICENSE ├── README.markdown ├── Rakefile ├── buildfile ├── do_h2.gemspec ├── ext-java │ └── src │ │ └── main │ │ └── java │ │ └── do_h2 │ │ ├── DoH2Service.java │ │ └── H2DriverDefinition.java ├── lib │ ├── do_h2.rb │ └── do_h2 │ │ └── version.rb ├── pom.xml ├── spec │ ├── command_spec.rb │ ├── connection_spec.rb │ ├── encoding_spec.rb │ ├── rcov.opts │ ├── reader_spec.rb │ ├── result_spec.rb │ ├── spec_helper.rb │ └── typecast │ │ ├── array_spec.rb │ │ ├── bigdecimal_spec.rb │ │ ├── boolean_spec.rb │ │ ├── byte_array_spec.rb │ │ ├── class_spec.rb │ │ ├── date_spec.rb │ │ ├── datetime_spec.rb │ │ ├── float_spec.rb │ │ ├── integer_spec.rb │ │ ├── nil_spec.rb │ │ ├── other_spec.rb │ │ ├── range_spec.rb │ │ ├── string_spec.rb │ │ └── time_spec.rb └── tasks │ ├── compile.rake │ ├── release.rake │ └── spec.rake ├── do_hsqldb ├── .gitignore ├── .rspec ├── ChangeLog.markdown ├── Gemfile ├── LICENSE ├── README.markdown ├── Rakefile ├── buildfile ├── do_hsqldb.gemspec ├── ext-java │ └── src │ │ └── main │ │ └── java │ │ └── do_hsqldb │ │ ├── DoHsqldbService.java │ │ └── HsqldbDriverDefinition.java ├── lib │ ├── do_hsqldb.rb │ └── do_hsqldb │ │ └── version.rb ├── pom.xml ├── spec │ ├── command_spec.rb │ ├── connection_spec.rb │ ├── encoding_spec.rb │ ├── rcov.opts │ ├── reader_spec.rb │ ├── result_spec.rb │ ├── spec_helper.rb │ ├── test.db.script │ └── typecast │ │ ├── array_spec.rb │ │ ├── bigdecimal_spec.rb │ │ ├── boolean_spec.rb │ │ ├── byte_array_spec.rb │ │ ├── class_spec.rb │ │ ├── date_spec.rb │ │ ├── datetime_spec.rb │ │ ├── float_spec.rb │ │ ├── integer_spec.rb │ │ ├── nil_spec.rb │ │ ├── other_spec.rb │ │ ├── range_spec.rb │ │ ├── string_spec.rb │ │ └── time_spec.rb └── tasks │ ├── compile.rake │ ├── release.rake │ └── spec.rake ├── do_jdbc-tools ├── pom.xml └── src │ └── main │ └── resources │ └── data_objects │ ├── LICENSE.txt │ └── checkstyle.xml ├── do_jdbc ├── .gitignore ├── ChangeLog.markdown ├── Gemfile ├── LICENSE ├── README.markdown ├── Rakefile ├── do_jdbc.gemspec ├── lib │ ├── do_jdbc.rb │ └── do_jdbc │ │ └── version.rb ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ └── data_objects │ │ │ ├── Command.java │ │ │ ├── Connection.java │ │ │ ├── DORubyObject.java │ │ │ ├── DataObjects.java │ │ │ ├── Reader.java │ │ │ ├── Result.java │ │ │ ├── RubyType.java │ │ │ ├── Transaction.java │ │ │ ├── drivers │ │ │ ├── AbstractDataObjectsService.java │ │ │ ├── AbstractDriverDefinition.java │ │ │ └── DriverDefinition.java │ │ │ ├── errors │ │ │ └── Errors.java │ │ │ └── util │ │ │ ├── JDBCUtil.java │ │ │ └── StringUtil.java │ └── test │ │ └── java │ │ └── data_objects │ │ └── drivers │ │ └── AbstractDriverDefinitionTestCase.java └── tasks │ ├── compile.rake │ └── release.rake ├── do_mysql ├── .gitignore ├── .rspec ├── ChangeLog.markdown ├── Gemfile ├── LICENSE ├── README.markdown ├── Rakefile ├── buildfile ├── do_mysql.gemspec ├── ext-java │ └── src │ │ └── main │ │ └── java │ │ └── do_mysql │ │ ├── DoMysqlService.java │ │ └── MySqlDriverDefinition.java ├── ext │ ├── .gitignore │ └── do_mysql │ │ ├── compat.h │ │ ├── do_common.c │ │ ├── do_common.h │ │ ├── do_mysql.c │ │ ├── error.h │ │ ├── extconf.rb │ │ └── mysql_compat.h ├── lib │ ├── do_mysql.rb │ └── do_mysql │ │ ├── encoding.rb │ │ ├── transaction.rb │ │ └── version.rb ├── pom.xml ├── spec │ ├── command_spec.rb │ ├── connection_spec.rb │ ├── encoding_spec.rb │ ├── error │ │ └── sql_error_spec.rb │ ├── rcov.opts │ ├── reader_spec.rb │ ├── result_spec.rb │ ├── spec_helper.rb │ └── typecast │ │ ├── array_spec.rb │ │ ├── bigdecimal_spec.rb │ │ ├── boolean_spec.rb │ │ ├── byte_array_spec.rb │ │ ├── class_spec.rb │ │ ├── date_spec.rb │ │ ├── datetime_spec.rb │ │ ├── float_spec.rb │ │ ├── integer_spec.rb │ │ ├── nil_spec.rb │ │ ├── other_spec.rb │ │ ├── range_spec.rb │ │ ├── string_spec.rb │ │ └── time_spec.rb └── tasks │ ├── compile.rake │ ├── release.rake │ ├── retrieve.rake │ ├── spec.rake │ └── ssl.rake ├── do_openedge ├── .rspec ├── ChangeLog.markdown ├── Gemfile ├── LICENSE ├── README.markdown ├── Rakefile ├── buildfile ├── do_openedge.gemspec ├── ext-java │ └── src │ │ └── main │ │ └── java │ │ └── do_openedge │ │ ├── DoOpenedgeService.java │ │ └── OpenEdgeDriverDefinition.java ├── lib │ ├── do_openedge.rb │ └── do_openedge │ │ └── version.rb ├── spec │ ├── command_spec.rb │ ├── connection_spec.rb │ ├── encoding_spec.rb │ ├── rcov.opts │ ├── reader_spec.rb │ ├── result_spec.rb │ ├── spec_helper.rb │ └── typecast │ │ ├── array_spec.rb │ │ ├── bigdecimal_spec.rb │ │ ├── boolean_spec.rb │ │ ├── byte_array_spec.rb │ │ ├── class_spec.rb │ │ ├── date_spec.rb │ │ ├── datetime_spec.rb │ │ ├── float_spec.rb │ │ ├── integer_spec.rb │ │ ├── nil_spec.rb │ │ ├── other_spec.rb │ │ ├── range_spec.rb │ │ ├── string_spec.rb │ │ └── time_spec.rb └── tasks │ ├── compile.rake │ ├── release.rake │ └── spec.rake ├── do_oracle ├── .gitignore ├── .rspec ├── ChangeLog.markdown ├── Gemfile ├── INSTALL.markdown ├── LICENSE ├── README.markdown ├── Rakefile ├── buildfile ├── do_oracle.gemspec ├── ext-java │ └── src │ │ └── main │ │ └── java │ │ └── do_oracle │ │ ├── DoOracleService.java │ │ └── OracleDriverDefinition.java ├── ext │ ├── .gitignore │ └── do_oracle │ │ ├── do_oracle.c │ │ └── extconf.rb ├── lib │ ├── do_oracle.rb │ └── do_oracle │ │ ├── transaction.rb │ │ └── version.rb ├── pom.xml ├── spec │ ├── command_spec.rb │ ├── connection_spec.rb │ ├── encoding_spec.rb │ ├── rcov.opts │ ├── reader_spec.rb │ ├── result_spec.rb │ ├── spec_helper.rb │ └── typecast │ │ ├── array_spec.rb │ │ ├── bigdecimal_spec.rb │ │ ├── boolean_spec.rb │ │ ├── byte_array_spec.rb │ │ ├── class_spec.rb │ │ ├── date_spec.rb │ │ ├── datetime_spec.rb │ │ ├── float_spec.rb │ │ ├── integer_spec.rb │ │ ├── nil_spec.rb │ │ ├── other_spec.rb │ │ ├── range_spec.rb │ │ ├── string_spec.rb │ │ └── time_spec.rb └── tasks │ ├── compile.rake │ ├── release.rake │ ├── retrieve.rake │ └── spec.rake ├── do_postgres ├── .gitignore ├── .rspec ├── ChangeLog.markdown ├── Gemfile ├── LICENSE ├── README.markdown ├── Rakefile ├── autobuild.rb ├── buildfile ├── do_postgres.gemspec ├── ext-java │ └── src │ │ └── main │ │ └── java │ │ └── do_postgres │ │ ├── DoPostgresService.java │ │ └── PostgresDriverDefinition.java ├── ext │ └── do_postgres │ │ ├── compat.h │ │ ├── do_common.c │ │ ├── do_common.h │ │ ├── do_postgres.c │ │ ├── error.h │ │ ├── extconf.rb │ │ └── pg_config.h ├── lib │ ├── do_postgres.rb │ └── do_postgres │ │ ├── encoding.rb │ │ ├── transaction.rb │ │ └── version.rb ├── pom.xml ├── script │ ├── timezone_spec_runner.rb │ └── timezones.txt ├── spec │ ├── command_spec.rb │ ├── connection_spec.rb │ ├── encoding_spec.rb │ ├── error │ │ └── sql_error_spec.rb │ ├── rcov.opts │ ├── reader_spec.rb │ ├── result_spec.rb │ ├── spec_helper.rb │ └── typecast │ │ ├── array_spec.rb │ │ ├── bigdecimal_spec.rb │ │ ├── boolean_spec.rb │ │ ├── byte_array_spec.rb │ │ ├── class_spec.rb │ │ ├── date_spec.rb │ │ ├── datetime_spec.rb │ │ ├── float_spec.rb │ │ ├── integer_spec.rb │ │ ├── nil_spec.rb │ │ ├── other_spec.rb │ │ ├── range_spec.rb │ │ ├── string_spec.rb │ │ └── time_spec.rb └── tasks │ ├── compile.rake │ ├── release.rake │ ├── retrieve.rake │ └── spec.rake ├── do_sqlite3 ├── .gitignore ├── .rspec ├── ChangeLog.markdown ├── Gemfile ├── LICENSE ├── README.markdown ├── Rakefile ├── buildfile ├── do_sqlite3.gemspec ├── ext-java │ └── src │ │ └── main │ │ └── java │ │ └── do_sqlite3 │ │ ├── DoSqlite3Service.java │ │ └── Sqlite3DriverDefinition.java ├── ext │ └── do_sqlite3 │ │ ├── compat.h │ │ ├── do_common.c │ │ ├── do_common.h │ │ ├── do_sqlite3.c │ │ ├── do_sqlite3.h │ │ ├── do_sqlite3_extension.c │ │ ├── error.h │ │ └── extconf.rb ├── lib │ ├── do_sqlite3.rb │ └── do_sqlite3 │ │ ├── transaction.rb │ │ └── version.rb ├── pom.xml ├── spec │ ├── command_spec.rb │ ├── connection_spec.rb │ ├── encoding_spec.rb │ ├── error │ │ └── sql_error_spec.rb │ ├── rcov.opts │ ├── reader_spec.rb │ ├── result_spec.rb │ ├── spec_helper.rb │ └── typecast │ │ ├── array_spec.rb │ │ ├── bigdecimal_spec.rb │ │ ├── boolean_spec.rb │ │ ├── byte_array_spec.rb │ │ ├── class_spec.rb │ │ ├── date_spec.rb │ │ ├── datetime_spec.rb │ │ ├── float_spec.rb │ │ ├── integer_spec.rb │ │ ├── nil_spec.rb │ │ ├── other_spec.rb │ │ ├── range_spec.rb │ │ ├── string_spec.rb │ │ └── time_spec.rb └── tasks │ ├── compile.rake │ ├── release.rake │ ├── retrieve.rake │ └── spec.rake ├── do_sqlserver ├── .gitignore ├── .rspec ├── CONNECTING.markdown ├── ChangeLog.markdown ├── FAQS.markdown ├── Gemfile ├── INSTALL.markdown ├── LICENSE ├── README.markdown ├── Rakefile ├── buildfile ├── do_sqlserver.gemspec ├── ext-java │ └── src │ │ └── main │ │ └── java │ │ └── do_sqlserver │ │ ├── DoSqlserverService.java │ │ └── SqlServerDriverDefinition.java ├── ext │ └── .gitignore ├── lib │ ├── dbd_odbc_patch.rb │ ├── do_sqlserver.rb │ └── do_sqlserver │ │ ├── transaction.rb │ │ └── version.rb ├── pom.xml ├── spec │ ├── command_spec.rb │ ├── connection_spec.rb │ ├── encoding_spec.rb │ ├── rcov.opts │ ├── reader_spec.rb │ ├── result_spec.rb │ ├── spec_helper.rb │ └── typecast │ │ ├── array_spec.rb │ │ ├── bigdecimal_spec.rb │ │ ├── boolean_spec.rb │ │ ├── byte_array_spec.rb │ │ ├── class_spec.rb │ │ ├── date_spec.rb │ │ ├── datetime_spec.rb │ │ ├── float_spec.rb │ │ ├── integer_spec.rb │ │ ├── nil_spec.rb │ │ ├── other_spec.rb │ │ ├── range_spec.rb │ │ ├── string_spec.rb │ │ └── time_spec.rb └── tasks │ ├── compile.rake │ ├── release.rake │ └── spec.rake ├── jdbc_drivers ├── README.developers ├── buildfile └── sqlserver │ ├── LGPL-LICENSE │ ├── README.markdown │ ├── Rakefile │ ├── do-jdbc_sqlserver.gemspec │ └── lib │ ├── do_jdbc │ ├── sqlserver.rb │ └── sqlserver_version.rb │ └── jtds-1.2.4.jar └── pom.xml /.gitignore: -------------------------------------------------------------------------------- 1 | ## MAC OS 2 | .DS_Store 3 | 4 | *.log* 5 | ./doc 6 | ./cov 7 | pkg/* 8 | _Yardoc 9 | *.o 10 | *.so 11 | .yardoc 12 | Makefile 13 | **/*.db 14 | mem.* 15 | testdb 16 | *.*~ 17 | *.*# 18 | *.rbc 19 | *.dSYM 20 | stash 21 | cross 22 | coverage 23 | **/test.*.* 24 | do_*/lib/do_*/*.jar 25 | do_*/**/target 26 | do_*/pkg 27 | do_*/target 28 | do_*/tmp 29 | do_*/vendor 30 | bin/** 31 | *.swp 32 | gem_make.out 33 | *.gem 34 | *.bundle 35 | 36 | ## BUNDLER 37 | Gemfile.* 38 | 39 | ## JAVA IDEs 40 | .classpath 41 | .project 42 | .settings 43 | *.ipr 44 | *.iws 45 | *.iml 46 | nb-configuration.xml 47 | nbproject 48 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | rvm: 2 | - 1.8.7 3 | - 1.9.2 4 | - 1.9.3 5 | - 2.0.0 6 | - 2.1.8 7 | - 2.2.4 8 | - 2.3.0 9 | - rbx-2 10 | - ree 11 | - jruby-18mode 12 | - jruby-19mode 13 | matrix: 14 | allow_failures: 15 | - rvm: 1.9.2 16 | - rvm: 1.8.7 17 | - rvm: ree 18 | - rvm: jruby-18mode 19 | - rvm: jruby-19mode 20 | before_install: 21 | - sudo apt-get update -qq 22 | - sudo apt-get install -y postgresql-server-dev-all 23 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gem 'addressable', '~> 2.1' 4 | gem 'rake' 5 | gem 'rake-compiler' 6 | gem 'rspec', '~> 2.5' 7 | 8 | platforms :jruby do 9 | gem 'jdbc-mysql', '>=5.0.4' 10 | gem 'jdbc-postgres', '>=8.2' 11 | gem 'jdbc-sqlite3', '>=3.5.8' 12 | gem 'jdbc-derby' 13 | gem 'jdbc-h2' 14 | gem 'jdbc-hsqldb' 15 | end 16 | -------------------------------------------------------------------------------- /data_objects/.autotest: -------------------------------------------------------------------------------- 1 | require 'autotest/bundler' 2 | -------------------------------------------------------------------------------- /data_objects/.gitignore: -------------------------------------------------------------------------------- 1 | pkg 2 | *.db 3 | -------------------------------------------------------------------------------- /data_objects/.rspec: -------------------------------------------------------------------------------- 1 | --format documentation 2 | --colour 3 | -------------------------------------------------------------------------------- /data_objects/.yardopts: -------------------------------------------------------------------------------- 1 | - 2 | LICENSE 3 | -------------------------------------------------------------------------------- /data_objects/Gemfile: -------------------------------------------------------------------------------- 1 | source :rubygems 2 | 3 | gemspec 4 | 5 | group :development do # Development dependencies (as in the gemspec) 6 | gem 'rake' 7 | end 8 | -------------------------------------------------------------------------------- /data_objects/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2007 - 2011 Yehuda Katz, Dirkjan Bussink 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /data_objects/README.markdown: -------------------------------------------------------------------------------- 1 | # data_objects 2 | 3 | * 4 | 5 | ## Description 6 | 7 | A unified Ruby API for popular databases. 8 | 9 | ## License 10 | 11 | Licensed under the MIT license. Please see the {file:LICENSE} for more information. 12 | 13 | ## Contact 14 | 15 | **IRC**: **Join us on IRC in #datamapper on irc.freenode.net!**
16 | **Git**:
17 | **Author**: Dirkjan Bussink
18 | **License**: MIT License 19 | -------------------------------------------------------------------------------- /data_objects/Rakefile: -------------------------------------------------------------------------------- 1 | require 'pathname' 2 | require 'rubygems' 3 | require 'bundler' 4 | require 'rubygems/package_task' 5 | Bundler::GemHelper.install_tasks 6 | 7 | require 'rake' 8 | require 'rake/clean' 9 | 10 | ROOT = Pathname(__FILE__).dirname.expand_path 11 | 12 | require ROOT + 'lib/data_objects/version' 13 | 14 | JRUBY = RUBY_PLATFORM =~ /java/ 15 | IRONRUBY = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ironruby' 16 | WINDOWS = Gem.win_platform? || (JRUBY && ENV_JAVA['os.name'] =~ /windows/i) 17 | SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS']) 18 | 19 | CLEAN.include(%w[ pkg/ **/*.rbc ]) 20 | 21 | FileList['tasks/**/*.rake'].each { |task| import task } 22 | -------------------------------------------------------------------------------- /data_objects/lib/data_objects.rb: -------------------------------------------------------------------------------- 1 | require 'data_objects/version' 2 | require 'data_objects/utilities' 3 | require 'data_objects/logger' 4 | require 'data_objects/byte_array' 5 | require 'data_objects/pooling' 6 | require 'data_objects/connection' 7 | require 'data_objects/uri' 8 | require 'data_objects/transaction' 9 | require 'data_objects/command' 10 | require 'data_objects/result' 11 | require 'data_objects/reader' 12 | require 'data_objects/quoting' 13 | require 'data_objects/extension' 14 | require 'data_objects/error' 15 | require 'data_objects/error/sql_error' 16 | require 'data_objects/error/connection_error' 17 | require 'data_objects/error/data_error' 18 | require 'data_objects/error/integrity_error' 19 | require 'data_objects/error/syntax_error' 20 | require 'data_objects/error/transaction_error' 21 | -------------------------------------------------------------------------------- /data_objects/lib/data_objects/byte_array.rb: -------------------------------------------------------------------------------- 1 | # This class has exists to represent binary data. This is mainly 2 | # used by DataObjects. Binary data sometimes needs to be quoted differently 3 | # than regular string data (even if the string is just plain ASCII). 4 | module Extlib 5 | class ByteArray < ::String; end 6 | end 7 | -------------------------------------------------------------------------------- /data_objects/lib/data_objects/error.rb: -------------------------------------------------------------------------------- 1 | module DataObjects 2 | class Error < StandardError 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /data_objects/lib/data_objects/error/connection_error.rb: -------------------------------------------------------------------------------- 1 | module DataObjects 2 | class ConnectionError < SQLError 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /data_objects/lib/data_objects/error/data_error.rb: -------------------------------------------------------------------------------- 1 | module DataObjects 2 | class DataError < SQLError 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /data_objects/lib/data_objects/error/integrity_error.rb: -------------------------------------------------------------------------------- 1 | module DataObjects 2 | class IntegrityError < SQLError 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /data_objects/lib/data_objects/error/sql_error.rb: -------------------------------------------------------------------------------- 1 | module DataObjects 2 | class SQLError < Error 3 | 4 | attr_reader :message 5 | attr_reader :code 6 | attr_reader :sqlstate 7 | attr_reader :query 8 | attr_reader :uri 9 | 10 | def initialize(message, code = nil, sqlstate = nil, query = nil, uri = nil) 11 | @message = message 12 | @code = code 13 | @sqlstate = sqlstate 14 | @query = query 15 | @uri = uri 16 | end 17 | 18 | def to_s 19 | "#{message} (code: #{code}, sql state: #{sqlstate}, query: #{query}, uri: #{uri})" 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /data_objects/lib/data_objects/error/syntax_error.rb: -------------------------------------------------------------------------------- 1 | module DataObjects 2 | class SyntaxError < SQLError 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /data_objects/lib/data_objects/error/transaction_error.rb: -------------------------------------------------------------------------------- 1 | module DataObjects 2 | class TransactionError < SQLError 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /data_objects/lib/data_objects/extension.rb: -------------------------------------------------------------------------------- 1 | module DataObjects 2 | class Extension 3 | 4 | attr_reader :connection 5 | 6 | def initialize(connection) 7 | @connection = connection 8 | end 9 | 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /data_objects/lib/data_objects/reader.rb: -------------------------------------------------------------------------------- 1 | module DataObjects 2 | # Abstract class to read rows from a query result 3 | class Reader 4 | 5 | include Enumerable 6 | 7 | # Return the array of field names 8 | def fields 9 | raise NotImplementedError.new 10 | end 11 | 12 | # Return the array of field values for the current row. Not legal after next! has returned false or before it's been called 13 | def values 14 | raise NotImplementedError.new 15 | end 16 | 17 | # Close the reader discarding any unread results. 18 | def close 19 | raise NotImplementedError.new 20 | end 21 | 22 | # Discard the current row (if any) and read the next one (returning true), or return nil if there is no further row. 23 | def next! 24 | raise NotImplementedError.new 25 | end 26 | 27 | # Return the number of fields in the result set. 28 | def field_count 29 | raise NotImplementedError.new 30 | end 31 | 32 | # Yield each row to the given block as a Hash 33 | def each 34 | begin 35 | while next! 36 | row = {} 37 | fields.each_with_index { |field, index| row[field] = values[index] } 38 | yield row 39 | end 40 | ensure 41 | close 42 | end 43 | self 44 | end 45 | 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /data_objects/lib/data_objects/result.rb: -------------------------------------------------------------------------------- 1 | module DataObjects 2 | # The Result class is returned from Connection#execute_non_query. 3 | class Result 4 | # The ID of a row inserted by the Command 5 | attr_accessor :insert_id 6 | # The number of rows affected by the Command 7 | attr_accessor :affected_rows 8 | 9 | # Create a new Result. Used internally in the adapters. 10 | def initialize(command, affected_rows, insert_id = nil) 11 | @command, @affected_rows, @insert_id = command, affected_rows, insert_id 12 | end 13 | 14 | # Return the number of affected rows 15 | def to_i 16 | @affected_rows 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /data_objects/lib/data_objects/spec/lib/pending_helpers.rb: -------------------------------------------------------------------------------- 1 | module DataObjects::Spec 2 | module PendingHelpers 3 | def pending_if(message, boolean) 4 | if boolean 5 | pending(message) { yield } 6 | else 7 | yield 8 | end 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /data_objects/lib/data_objects/spec/lib/ssl.rb: -------------------------------------------------------------------------------- 1 | require 'pathname' 2 | require 'cgi' 3 | 4 | module SSLHelpers 5 | 6 | CERTS_DIR = Pathname(__FILE__).dirname.join('ssl_certs').to_s 7 | 8 | CONFIG = OpenStruct.new 9 | CONFIG.ca_cert = File.join(CERTS_DIR, 'ca-cert.pem') 10 | CONFIG.ca_key = File.join(CERTS_DIR, 'ca-key.pem') 11 | CONFIG.server_cert = File.join(CERTS_DIR, 'server-cert.pem') 12 | CONFIG.server_key = File.join(CERTS_DIR, 'server-key.pem') 13 | CONFIG.client_cert = File.join(CERTS_DIR, 'client-cert.pem') 14 | CONFIG.client_key = File.join(CERTS_DIR, 'client-key.pem') 15 | CONFIG.cipher = 'AES128-SHA' 16 | 17 | def self.query(*keys) 18 | keys.map { |key| "ssl[#{key}]=#{CGI::escape(CONFIG.send(key))}" }.join('&') 19 | end 20 | 21 | end 22 | -------------------------------------------------------------------------------- /data_objects/lib/data_objects/spec/lib/ssl_certs/client-cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICkjCCAXoCAQEwDQYJKoZIhvcNAQEEBQAwTzELMAkGA1UEBhMCVFgxDzANBgNV 3 | BAgTBkF1c3RpbjETMBEGA1UEChMKRGF0YU1hcHBlcjENMAsGA1UECxMEVGVzdDEL 4 | MAkGA1UEAxMCQ0EwHhcNMDkwMzI0MDE0MjE2WhcNMTAxMDI0MTI0NTQ0WjBTMQsw 5 | CQYDVQQGEwJUWDEPMA0GA1UECBMGQXVzdGluMRMwEQYDVQQKEwpEYXRhTWFwcGVy 6 | MQ0wCwYDVQQLEwRUZXN0MQ8wDQYDVQQDEwZjbGllbnQwgZ8wDQYJKoZIhvcNAQEB 7 | BQADgY0AMIGJAoGBANHuoOK1P+ZDNymVPCa45ng6DdspYYTC5q0gqR1l0TgZOjms 8 | 0SZdBVYDaX3Mcz9RTDB1SkyUEbKR0lw4MBcO4lOqT6FiOgNs4PWpBnX63lyyYi1Y 9 | ahx/94MeSidZRQAg/kJD5ceTVX6JlcqdD+DLUqm6/fVVexA3pUIWr1jNQkZ7AgMB 10 | AAEwDQYJKoZIhvcNAQEEBQADggEBADwHH6hNXKS/ZDYM56UTXj6dseUEyiXkW+vl 11 | jqwbQ273QtkL61JLLKg778MZoHYM2nqD2QLtYfpt6doDQdlBzloapshP8X/swawG 12 | Y0BRVAfyB72k4jCiZdTgJDwB+aA98eAmYNUiSelADwJnZ9o0FThiAkQb9103jEzd 13 | e2dpZQtDhSc7+sB4JZ4hoGnnRIpP3jLMbSe/cYeb9j3WipXRG76/Y/Yybn6FuNGU 14 | 0Dw3hxWQjjzAumTXSWnOqjVBImRzHYmne6A6CUGUNm1pCjwcdeFw0Bc7FjuDp+R9 15 | sZRAfrSkabopuWnvcBucSIlAVNHWej8Gf8zFXsjHqZr29J7EyTo= 16 | -----END CERTIFICATE----- 17 | -------------------------------------------------------------------------------- /data_objects/lib/data_objects/spec/lib/ssl_certs/client-key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXQIBAAKBgQDR7qDitT/mQzcplTwmuOZ4Og3bKWGEwuatIKkdZdE4GTo5rNEm 3 | XQVWA2l9zHM/UUwwdUpMlBGykdJcODAXDuJTqk+hYjoDbOD1qQZ1+t5csmItWGoc 4 | f/eDHkonWUUAIP5CQ+XHk1V+iZXKnQ/gy1Kpuv31VXsQN6VCFq9YzUJGewIDAQAB 5 | AoGAVHxrxTFaeQnd/l8v6QmKvyHmB6ictXhWq6A0Tz91ttT4SNPTDFRtXFNdNiJ8 6 | 0yOdvPbHIxCIGsxy02hNekokLPqqa/J3ZvUo1RKylVO/IDIA5Pn+wr6BCKTLLPvw 7 | PJe5LyfbZ96tQ7X2PiCi6pWywmpSIvSy1/pqijGkWOwj+BkCQQD2+bEjgJThWA/3 8 | wN8P3y9WXJnK/H5/enihE8gq/DvGJZ7sCO+RR8ugReMGRhEic6AlDA+Vujab57x2 9 | I1iebGEXAkEA2ZprT35CSgokaJXyU88pT4xqIKxXR75XtAtTvu7aiyVxr6PGMkg5 10 | J7QrHa8i8Te2Onp4XLkqd8Yil+mwVdh8PQJAcvUsX7MVGYLtA8xRx8iB9zfpGhPH 11 | Kb0u8wMLM/7uL8AJJiLOqBf8DyEYmC37AcdCLpxbkLz5eD44eeDf+fXGhwJBAJhd 12 | oOAzlzUCrwWwYNLATrvNpQ4lvqOUqxJ9j/E0jEA8QsNqWMAihCrB5CLP3BatHOML 13 | mDXMzei6CsT2M6uYfz0CQQC/IXZNAObXg9Zrl2nvWjNcjrE4x70n9s/Er7ToDHKk 14 | BGJ4AISDD4FMawDvfDK8Pjc2/HkTty8S2JvduAcwQFWO 15 | -----END RSA PRIVATE KEY----- 16 | -------------------------------------------------------------------------------- /data_objects/lib/data_objects/spec/lib/ssl_certs/client-req.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE REQUEST----- 2 | MIIBkjCB/AIBADBTMQswCQYDVQQGEwJUWDEPMA0GA1UECBMGQXVzdGluMRMwEQYD 3 | VQQKEwpEYXRhTWFwcGVyMQ0wCwYDVQQLEwRUZXN0MQ8wDQYDVQQDEwZjbGllbnQw 4 | gZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANHuoOK1P+ZDNymVPCa45ng6Ddsp 5 | YYTC5q0gqR1l0TgZOjms0SZdBVYDaX3Mcz9RTDB1SkyUEbKR0lw4MBcO4lOqT6Fi 6 | OgNs4PWpBnX63lyyYi1Yahx/94MeSidZRQAg/kJD5ceTVX6JlcqdD+DLUqm6/fVV 7 | exA3pUIWr1jNQkZ7AgMBAAGgADANBgkqhkiG9w0BAQQFAAOBgQDG/9+D0C2Iwl6Y 8 | Bh2pT3uDufeP+ZkA28PKJyicZPSfvcpsnOzcAc41MQgPBd5qRoqJuVO4XnXnJkTD 9 | j+KDEkN/2le8jA1kNOEjAslMCsK7x1vxnQb6F4koQc7wvOyZ17NKYJzILpqp0SmZ 10 | cklV/Jvwx22GVVrpkLe1lacvk5qjzA== 11 | -----END CERTIFICATE REQUEST----- 12 | -------------------------------------------------------------------------------- /data_objects/lib/data_objects/spec/lib/ssl_certs/server-cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICkjCCAXoCAQEwDQYJKoZIhvcNAQEEBQAwTzELMAkGA1UEBhMCVFgxDzANBgNV 3 | BAgTBkF1c3RpbjETMBEGA1UEChMKRGF0YU1hcHBlcjENMAsGA1UECxMEVGVzdDEL 4 | MAkGA1UEAxMCQ0EwHhcNMDkwMzI0MDE0MjE2WhcNMTAxMDI0MTI0NTQ0WjBTMQsw 5 | CQYDVQQGEwJUWDEPMA0GA1UECBMGQXVzdGluMRMwEQYDVQQKEwpEYXRhTWFwcGVy 6 | MQ0wCwYDVQQLEwRUZXN0MQ8wDQYDVQQDEwZzZXJ2ZXIwgZ8wDQYJKoZIhvcNAQEB 7 | BQADgY0AMIGJAoGBAPo8V/AQX29BFFCcimsp7MdBHll0S0/5LX+Xw2MHTFRCaFMm 8 | 92wgsyVZqBkQYvRFVmPq5azeN2mpgKS+1NmmLpXpbdtEIH+pZIlxfbhZs9XhqiNz 9 | c2Sosqe6PAtvl+cvnx7RTfSq/VdIHZU4engL/44mCG94d0HHbrrBxRxYEN6PAgMB 10 | AAEwDQYJKoZIhvcNAQEEBQADggEBAG4fdY+G2BoLr6ntXg3Za7lWMkabl3lytmLM 11 | BBc2MONPX5d3jYGlwwHPjxWDcssoYpHovgtifPO0GrckMlgqQqGSE90ah+kHgOfV 12 | ijCN0pxyRaGzbCNxZxk09pq7vAh4V0hFufD4xV50ekS2iYaUIlYSder5FTowBgjI 13 | I8lFoe6l8yNT4LUU4aZRONFKvJ/+nNV9OMtaJQlTeqD4fmzj8Wce8bxDRIsRsNxT 14 | gSpJMJvVK6Qw701pxcf2JxfPnxh2/LNmiwqB0eJ8+vx6q+3TbE0ObcKQlvRNhb4B 15 | aTeG6H+UdYoAVM0MWyzi3FBhGtLgm2HH4zQpuwh6xkNo1GtwMjk= 16 | -----END CERTIFICATE----- 17 | -------------------------------------------------------------------------------- /data_objects/lib/data_objects/spec/lib/ssl_certs/server-key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXAIBAAKBgQD6PFfwEF9vQRRQnIprKezHQR5ZdEtP+S1/l8NjB0xUQmhTJvds 3 | ILMlWagZEGL0RVZj6uWs3jdpqYCkvtTZpi6V6W3bRCB/qWSJcX24WbPV4aojc3Nk 4 | qLKnujwLb5fnL58e0U30qv1XSB2VOHp4C/+OJghveHdBx266wcUcWBDejwIDAQAB 5 | AoGAJafK+98a3V0Ht5G26qVmch2EeaWcZ65xgE/QISjJ/av4kvq8JNNO4gH537ut 6 | iGCevW5tnXPbFtVg/GmTEiWFwNEw2Amw7BE9vGtaQTNMG9kxFwjlQICMLbDMyrGu 7 | x/jArxKiRezFf4XH84CiCmmACMMz4ygW3oqQS3VbmwIUKoECQQD+HVnPzkrxiUpn 8 | e62yUulFN33+igi8yZD0UptSNb+rur52FNuE+QCsABLJUQzuxh8Ul9u0snmadiEo 9 | cWXOw8ohAkEA/BegEjndBu4nE8184bLe3xWN4xIhDbDA4L16VHr6uTF6Epvhd4pu 10 | TWxw7Fgdt/nHCM4EedbH07R8K9wJP1dyrwJAFpr50FijphT2f3orG3/wrG2hUbFp 11 | 0ZGEyZdHpeqOIHK+WrbESHH2M1bWVP5Wzi7luOlBbDOsSadUj8p2qgwUwQJAIfsF 12 | Rq+qDX8YoWC3jqzPwf5jy9Hrxq6msSSZUr3pAgGbVNrSP4zXZXRSnGkcSGpQ2+z5 13 | SXscIHtZqYfVb0ZYXQJBANkra09OtrxnokBkvU8/1rFHvh7v/cCSIKJS4HIKLoo4 14 | rXDY/kl9LzoRhMpg93JwmW0lbYOSVpv029NZeAwPMBI= 15 | -----END RSA PRIVATE KEY----- 16 | -------------------------------------------------------------------------------- /data_objects/lib/data_objects/spec/lib/ssl_certs/server-req.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE REQUEST----- 2 | MIIBkjCB/AIBADBTMQswCQYDVQQGEwJUWDEPMA0GA1UECBMGQXVzdGluMRMwEQYD 3 | VQQKEwpEYXRhTWFwcGVyMQ0wCwYDVQQLEwRUZXN0MQ8wDQYDVQQDEwZzZXJ2ZXIw 4 | gZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAPo8V/AQX29BFFCcimsp7MdBHll0 5 | S0/5LX+Xw2MHTFRCaFMm92wgsyVZqBkQYvRFVmPq5azeN2mpgKS+1NmmLpXpbdtE 6 | IH+pZIlxfbhZs9XhqiNzc2Sosqe6PAtvl+cvnx7RTfSq/VdIHZU4engL/44mCG94 7 | d0HHbrrBxRxYEN6PAgMBAAGgADANBgkqhkiG9w0BAQQFAAOBgQDmvck8AWcjuWWZ 8 | 6Qvlx3zLBv0nE+ilqwRw6uDPVAqGMlmsS1wB0y9v9kPPplg35cFY8FzvltOC8F5x 9 | nZFUJ2c6cLhBZOEbAQDQ1mhJbvkGfdP3w9YzkHSceUzji8KOaktjG+gnIg32chhY 10 | 9tyr1AotCfvTGmCGXTZK9NzulDc9iA== 11 | -----END CERTIFICATE REQUEST----- 12 | -------------------------------------------------------------------------------- /data_objects/lib/data_objects/spec/setup.rb: -------------------------------------------------------------------------------- 1 | RSpec::Matchers.define :be_array_case_insensitively_equal_to do |attribute| 2 | match do |model| 3 | model.map { |f| f.downcase } == attribute 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /data_objects/lib/data_objects/spec/shared/error/sql_error_spec.rb: -------------------------------------------------------------------------------- 1 | shared_examples_for 'raising a SQLError' do 2 | 3 | before :all do 4 | setup_test_environment 5 | end 6 | 7 | describe "an invalid query" do 8 | 9 | it 'should raise an error' do 10 | @connection = DataObjects::Connection.new(CONFIG.uri) 11 | invalid_query = @connection.create_command("SLCT * FROM widgets WHERE ad_description = ? order by id") 12 | expect { invalid_query.execute_reader('Buy this product now!') }.to raise_error(DataObjects::SQLError) 13 | @connection.close 14 | end 15 | 16 | end 17 | 18 | 19 | describe "an invalid result set" do 20 | 21 | it 'should raise an error' do 22 | @connection = DataObjects::Connection.new(CONFIG.uri) 23 | invalid_result = @connection.create_command("SELECT MAX((SELECT 1 UNION SELECT 2))") 24 | expect { invalid_result.execute_reader }.to raise_error(DataObjects::SQLError) 25 | @connection.close 26 | end 27 | 28 | end 29 | 30 | end 31 | -------------------------------------------------------------------------------- /data_objects/lib/data_objects/spec/shared/quoting_spec.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datamapper/do/16564e6dba587e92e41aba376b46ef765f3bffea/data_objects/lib/data_objects/spec/shared/quoting_spec.rb -------------------------------------------------------------------------------- /data_objects/lib/data_objects/spec/shared/typecast/array_spec.rb: -------------------------------------------------------------------------------- 1 | shared_examples_for 'supporting Array' do 2 | 3 | before :all do 4 | setup_test_environment 5 | end 6 | 7 | before do 8 | @connection = DataObjects::Connection.new(CONFIG.uri) 9 | end 10 | 11 | after do 12 | @connection.close 13 | end 14 | 15 | describe 'passing an Array as a parameter in execute_reader' do 16 | 17 | before do 18 | @reader = @connection.create_command("SELECT * FROM widgets WHERE id in ?").execute_reader([2,3,4,5]) 19 | end 20 | 21 | after do 22 | @reader.close 23 | end 24 | 25 | it 'should return correct number of rows' do 26 | counter = 0 27 | while(@reader.next!) do 28 | counter += 1 29 | end 30 | counter.should == 4 31 | end 32 | 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /data_objects/lib/data_objects/spec/shared/typecast/ipaddr_spec.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datamapper/do/16564e6dba587e92e41aba376b46ef765f3bffea/data_objects/lib/data_objects/spec/shared/typecast/ipaddr_spec.rb -------------------------------------------------------------------------------- /data_objects/lib/data_objects/spec/shared/typecast/other_spec.rb: -------------------------------------------------------------------------------- 1 | class ::CustomTextType 2 | 3 | def initialize(value) 4 | @value = value 5 | end 6 | 7 | def to_s 8 | @value.to_s 9 | end 10 | 11 | end 12 | 13 | shared_examples_for 'supporting other (unknown) type' do 14 | 15 | before :all do 16 | setup_test_environment 17 | end 18 | 19 | describe 'writing an object of unknown type' do 20 | 21 | before do 22 | @connection = DataObjects::Connection.new(CONFIG.uri) 23 | end 24 | 25 | after do 26 | @connection.close 27 | end 28 | 29 | before do 30 | @command = @connection.create_command("SELECT ad_description FROM widgets WHERE ad_description = ?") 31 | @command.set_types(::CustomTextType) 32 | @reader = @command.execute_reader('Buy this product now!') 33 | @reader.next! 34 | @values = @reader.values 35 | end 36 | 37 | after do 38 | @reader.close 39 | end 40 | 41 | it 'should return the correct entry' do 42 | @values.first.should == 'Buy this product now!' 43 | end 44 | 45 | end 46 | 47 | end 48 | -------------------------------------------------------------------------------- /data_objects/lib/data_objects/spec/shared/typecast/range_spec.rb: -------------------------------------------------------------------------------- 1 | shared_examples_for 'supporting Range' do 2 | 3 | before :all do 4 | setup_test_environment 5 | end 6 | 7 | before do 8 | @connection = DataObjects::Connection.new(CONFIG.uri) 9 | end 10 | 11 | after do 12 | @connection.close 13 | end 14 | 15 | describe 'passing a Range as a parameter in execute_reader' do 16 | 17 | before do 18 | @reader = @connection.create_command("SELECT * FROM widgets WHERE id between ?").execute_reader(2..5) 19 | end 20 | 21 | after do 22 | @reader.close 23 | end 24 | 25 | it 'should return correct number of rows' do 26 | counter = 0 27 | while(@reader.next!) do 28 | counter += 1 29 | end 30 | counter.should == 4 31 | end 32 | 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /data_objects/lib/data_objects/utilities.rb: -------------------------------------------------------------------------------- 1 | # This is here to remove DataObject's dependency on Extlib. 2 | 3 | module DataObjects 4 | # @param name The name of the constant to get, e.g. "Merb::Router". 5 | # 6 | # @return The constant corresponding to the name. 7 | def self.full_const_get(name) 8 | list = name.split("::") 9 | list.shift if list.first.nil? || list.first.strip.empty? 10 | obj = ::Object 11 | list.each do |x| 12 | # This is required because const_get tries to look for constants in the 13 | # ancestor chain, but we only want constants that are HERE 14 | obj = obj.const_defined?(x) ? obj.const_get(x) : obj.const_missing(x) 15 | end 16 | obj 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /data_objects/lib/data_objects/version.rb: -------------------------------------------------------------------------------- 1 | module DataObjects 2 | VERSION = '0.10.17' 3 | end 4 | -------------------------------------------------------------------------------- /data_objects/spec/command_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 2 | 3 | describe DataObjects::Command do 4 | before do 5 | @connection = DataObjects::Connection.new('mock://localhost') 6 | @command = DataObjects::Command.new(@connection, 'SQL STRING') 7 | end 8 | 9 | after do 10 | @connection.close 11 | end 12 | 13 | %w{connection execute_non_query execute_reader set_types}.each do |meth| 14 | it "should respond to ##{meth}" do 15 | @command.should respond_to(meth.intern) 16 | end 17 | end 18 | 19 | %w{execute_non_query execute_reader set_types}.each do |meth| 20 | it "should raise NotImplementedError on ##{meth}" do 21 | lambda { @command.send(meth.intern, nil) }.should raise_error(NotImplementedError) 22 | end 23 | end 24 | 25 | end 26 | -------------------------------------------------------------------------------- /data_objects/spec/do_mock.rb: -------------------------------------------------------------------------------- 1 | module DataObjects 2 | 3 | module Mock 4 | class Connection < DataObjects::Connection 5 | def initialize(uri) 6 | @uri = uri 7 | end 8 | 9 | def dispose 10 | nil 11 | end 12 | end 13 | 14 | class Command < DataObjects::Command 15 | def execute_non_query(*args) 16 | Result.new(self, 0, nil) 17 | end 18 | 19 | def execute_reader(*args) 20 | Reader.new 21 | end 22 | end 23 | 24 | class Result < DataObjects::Result 25 | end 26 | 27 | class Reader < DataObjects::Reader 28 | end 29 | end 30 | 31 | end 32 | -------------------------------------------------------------------------------- /data_objects/spec/do_mock2.rb: -------------------------------------------------------------------------------- 1 | module DataObjects 2 | 3 | module Mock2 4 | class Connection < DataObjects::Connection 5 | def initialize(uri) 6 | @uri = uri 7 | end 8 | 9 | def dispose 10 | nil 11 | end 12 | end 13 | 14 | class Command < DataObjects::Command 15 | def execute_non_query(*args) 16 | Result.new(self, 0, nil) 17 | end 18 | 19 | def execute_reader(*args) 20 | Reader.new 21 | end 22 | end 23 | 24 | class Result < DataObjects::Result 25 | end 26 | 27 | class Reader < DataObjects::Reader 28 | end 29 | end 30 | 31 | end 32 | -------------------------------------------------------------------------------- /data_objects/spec/rcov.opts: -------------------------------------------------------------------------------- 1 | --exclude "spec,^/" 2 | --sort coverage 3 | --callsites 4 | --xrefs 5 | --profile 6 | --text-summary 7 | -------------------------------------------------------------------------------- /data_objects/spec/reader_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 2 | 3 | describe DataObjects::Reader do 4 | subject { command.execute_reader } 5 | 6 | let(:connection) { DataObjects::Connection.new('mock://localhost') } 7 | let(:command) { connection.create_command('SELECT * FROM example') } 8 | 9 | after { connection.close } 10 | 11 | context 'should define a standard API' do 12 | 13 | it { should be_a(Enumerable) } 14 | 15 | it { should respond_to(:close) } 16 | it { should respond_to(:next!) } 17 | it { should respond_to(:values) } 18 | it { should respond_to(:fields) } 19 | it { should respond_to(:each) } 20 | end 21 | 22 | end 23 | -------------------------------------------------------------------------------- /data_objects/spec/result_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 2 | 3 | describe DataObjects::Result do 4 | subject { command.execute_non_query } 5 | 6 | let(:connection) { DataObjects::Connection.new('mock://localhost') } 7 | let(:command) { connection.create_command('SELECT * FROM example') } 8 | 9 | after { connection.close } 10 | 11 | context 'should define a standard API' do 12 | 13 | it 'should provide the number of affected rows' do 14 | should respond_to(:to_i) 15 | subject.to_i.should == 0 16 | end 17 | 18 | it 'should provide the id of the inserted row' do 19 | should respond_to(:insert_id) 20 | end 21 | 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /data_objects/spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'data_objects' 3 | require 'rspec' 4 | 5 | module DataObjects::Pooling 6 | class << self 7 | remove_method :scavenger_interval if instance_methods(false).any? { |m| m.to_sym == :scavenger_interval } 8 | def scavenger_interval 9 | 0.5 10 | end 11 | end 12 | end 13 | 14 | require File.expand_path(File.join(File.dirname(__FILE__), 'do_mock')) 15 | require File.expand_path(File.join(File.dirname(__FILE__), 'do_mock2')) 16 | -------------------------------------------------------------------------------- /data_objects/tasks/release.rake: -------------------------------------------------------------------------------- 1 | desc 'Builds all gems (native, binaries for JRuby and Windows)' 2 | task :build_all do 3 | `rake clean` 4 | `rake build` 5 | end 6 | 7 | desc 'Release all gems (native, binaries for JRuby and Windows)' 8 | task :release_all => :build_all do 9 | Dir["pkg/data_objects-#{DataObjects::VERSION}*.gem"].each do |gem_path| 10 | command = "gem push #{gem_path}" 11 | puts "Executing #{command.inspect}:" 12 | sh command 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /data_objects/tasks/spec.rake: -------------------------------------------------------------------------------- 1 | require 'rspec/core/rake_task' 2 | 3 | RSpec::Core::RakeTask.new(:spec) do |spec| 4 | spec.pattern = './spec/**/*_spec.rb' 5 | end 6 | 7 | RSpec::Core::RakeTask.new(:rcov) do |rcov| 8 | rcov.pattern = "./spec/**/*_spec.rb" 9 | rcov.rcov = true 10 | rcov.rcov_opts = File.read('spec/rcov.opts').split(/\s+/) 11 | end 12 | -------------------------------------------------------------------------------- /data_objects/tasks/yard.rake: -------------------------------------------------------------------------------- 1 | begin 2 | require 'yard' 3 | 4 | YARD::Rake::YardocTask.new 5 | rescue LoadError 6 | task :yard do 7 | abort 'YARD is not available. In order to run yard, you must: gem install yard' 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /data_objects/tasks/yardstick.rake: -------------------------------------------------------------------------------- 1 | begin 2 | require 'pathname' 3 | require 'yardstick/rake/measurement' 4 | require 'yardstick/rake/verify' 5 | 6 | # yardstick_measure task 7 | Yardstick::Rake::Measurement.new 8 | 9 | # verify_measurements task 10 | Yardstick::Rake::Verify.new do |verify| 11 | verify.threshold = 100 12 | end 13 | rescue LoadError 14 | %w[ yardstick_measure verify_measurements ].each do |name| 15 | task name.to_s do 16 | abort "Yardstick is not available. In order to run #{name}, you must: gem install yardstick" 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /do_derby/.gitignore: -------------------------------------------------------------------------------- 1 | testdb 2 | test.db 3 | -------------------------------------------------------------------------------- /do_derby/.rspec: -------------------------------------------------------------------------------- 1 | --format documentation 2 | --colour 3 | -------------------------------------------------------------------------------- /do_derby/Gemfile: -------------------------------------------------------------------------------- 1 | source :rubygems 2 | 3 | path '../' 4 | 5 | gemspec 6 | 7 | group :development do # Development dependencies (as in the gemspec) 8 | gem 'rake' 9 | end 10 | -------------------------------------------------------------------------------- /do_derby/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008 - 2011 Alex Coles, Ikonoklastik Productions 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /do_derby/Rakefile: -------------------------------------------------------------------------------- 1 | require 'pathname' 2 | require 'rubygems' 3 | require 'bundler' 4 | require 'rubygems/package_task' 5 | Bundler::GemHelper.install_tasks 6 | 7 | require 'rake' 8 | require 'rake/clean' 9 | 10 | ROOT = Pathname(__FILE__).dirname.expand_path 11 | 12 | require ROOT + 'lib/do_derby/version' 13 | 14 | JRUBY = RUBY_PLATFORM =~ /java/ 15 | IRONRUBY = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ironruby' 16 | WINDOWS = Gem.win_platform? || (JRUBY && ENV_JAVA['os.name'] =~ /windows/i) 17 | SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS']) 18 | 19 | CLEAN.include(%w[ {tmp,pkg}/ **/*.{o,so,bundle,jar,log,a,gem,dSYM,obj,pdb,exp,DS_Store,rbc,db} ext-java/target ]) 20 | 21 | 22 | Rake::Task['build'].clear_actions if Rake::Task.task_defined?('build') 23 | task :build => [ :java, :gem ] 24 | 25 | FileList['tasks/**/*.rake'].each { |task| import task } 26 | -------------------------------------------------------------------------------- /do_derby/buildfile: -------------------------------------------------------------------------------- 1 | # Apache Buildr buildfile for do_derby 2 | # see http://incubator.apache.org/buildr/ for more information on Apache Buildr 3 | require 'buildr' 4 | require 'pathname' 5 | 6 | VERSION_NUMBER = '1.0' 7 | JDBC_SUPPORT = ['data_objects:jdbc:jar:1.0'] 8 | TARGET_DIR = 'pkg/classes' 9 | repositories.remote << 'http://www.ibiblio.org/maven2/' 10 | 11 | define 'do_derby' do 12 | project.version = VERSION_NUMBER 13 | project.group = 'data_objects.rb' 14 | 15 | manifest['Copyright'] = 'Alex Coles (C) 2008-2011' 16 | 17 | compile.using :target => '1.5', :lint => 'all', :deprecation => 'true' 18 | 19 | define 'ext-java' do 20 | package(:jar).clean.include(TARGET_DIR) 21 | 22 | jdbc_support_jar = file('../../do_jdbc/lib/do_jdbc_internal.jar') 23 | jdbc_support = artifact('data_objects:jdbc:jar:1.0').from(jdbc_support_jar) 24 | 25 | compile.into(TARGET_DIR).with(JDBC_SUPPORT) 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /do_derby/ext-java/src/main/java/do_derby/DoDerbyService.java: -------------------------------------------------------------------------------- 1 | package do_derby; 2 | 3 | import data_objects.drivers.AbstractDataObjectsService; 4 | import data_objects.drivers.DriverDefinition; 5 | 6 | public class DoDerbyService extends AbstractDataObjectsService { 7 | 8 | private final static DriverDefinition driver = new DerbyDriverDefinition(); 9 | 10 | /** 11 | * 12 | * @return 13 | */ 14 | @Override 15 | public DriverDefinition getDriverDefinition() { 16 | return driver; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /do_derby/lib/do_derby.rb: -------------------------------------------------------------------------------- 1 | require 'data_objects' 2 | 3 | if RUBY_PLATFORM =~ /java/ 4 | require 'do_jdbc' 5 | require 'java' 6 | 7 | module DataObjects 8 | module Derby 9 | JDBC_DRIVER = 'org.apache.derby.jdbc.EmbeddedDriver' 10 | end 11 | end 12 | 13 | begin 14 | java.lang.Thread.currentThread.getContextClassLoader().loadClass(DataObjects::Derby::JDBC_DRIVER, true) 15 | rescue java.lang.ClassNotFoundException 16 | require 'jdbc/derby' # the JDBC driver, packaged as a gem 17 | Jdbc::Derby.load_driver if Jdbc::Derby.respond_to?(:load_driver) 18 | end 19 | 20 | require 'do_derby/do_derby' # the Java extension for this DO driver 21 | 22 | # Another way of loading the JDBC Class. This seems to be more reliable 23 | # than Class.forName() within the data_objects.Connection Java class, 24 | # which is currently not working as expected. 25 | java_import DataObjects::Derby::JDBC_DRIVER 26 | 27 | else 28 | warn "do_derby is only for use with JRuby" 29 | end 30 | -------------------------------------------------------------------------------- /do_derby/lib/do_derby/version.rb: -------------------------------------------------------------------------------- 1 | module DataObjects 2 | module Derby 3 | VERSION = '0.10.17' 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /do_derby/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.dataobjects 6 | dataobjects 7 | 0.10.17 8 | ../pom.xml 9 | 10 | do_derby 11 | jar 12 | do_derby 13 | A DataObjects.rb driver for Derby 14 | 15 | 16 | ${pom.parent.groupId} 17 | do_jdbc 18 | ${pom.parent.version} 19 | 20 | 21 | org.apache.derby 22 | derby 23 | 10.5.3.0_1 24 | 25 | 26 | 27 | 28 | skip_derby 29 | 30 | true 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /do_derby/spec/command_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/command_spec' 5 | 6 | describe DataObjects::Derby::Command do 7 | it_should_behave_like 'a Command' 8 | # it_should_behave_like 'a Command with async' 9 | end 10 | -------------------------------------------------------------------------------- /do_derby/spec/connection_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/connection_spec' 5 | 6 | describe DataObjects::Derby::Connection do 7 | 8 | before :all do 9 | @driver = 'derby' 10 | @user = '' 11 | @password = '' 12 | @host = '' 13 | @port = '' 14 | @database = "#{File.expand_path(File.dirname(__FILE__))}/test.db;create=true" 15 | end 16 | 17 | it_should_behave_like 'a Connection' 18 | #it_should_behave_like 'a Connection with authentication support' 19 | it_should_behave_like 'a Connection with JDBC URL support' 20 | it_should_behave_like 'a Connection via JDNI' 21 | end 22 | -------------------------------------------------------------------------------- /do_derby/spec/encoding_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/encoding_spec' 5 | 6 | describe DataObjects::Derby::Connection do 7 | # it_should_behave_like 'a driver supporting different encodings' 8 | end 9 | -------------------------------------------------------------------------------- /do_derby/spec/rcov.opts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datamapper/do/16564e6dba587e92e41aba376b46ef765f3bffea/do_derby/spec/rcov.opts -------------------------------------------------------------------------------- /do_derby/spec/reader_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/reader_spec' 5 | 6 | describe DataObjects::Derby::Reader do 7 | it_should_behave_like 'a Reader' 8 | end 9 | -------------------------------------------------------------------------------- /do_derby/spec/result_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/result_spec' 5 | 6 | # splitting the descibe into two separate declaration avoids 7 | # concurrent execution of the "it_should_behave_like ....." 8 | # needed by some databases (sqlite3) 9 | 10 | describe DataObjects::Derby::Result do 11 | it_should_behave_like 'a Result' 12 | end 13 | 14 | describe DataObjects::Derby::Result do 15 | it_should_behave_like 'a Result which returns inserted key with sequences' 16 | end 17 | -------------------------------------------------------------------------------- /do_derby/spec/typecast/array_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/array_spec' 5 | 6 | describe 'DataObjects::Derby with Array' do 7 | it_should_behave_like 'supporting Array' 8 | end 9 | -------------------------------------------------------------------------------- /do_derby/spec/typecast/bigdecimal_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/bigdecimal_spec' 5 | 6 | describe 'DataObjects::Derby with BigDecimal' do 7 | it_should_behave_like 'supporting BigDecimal' 8 | it_should_behave_like 'supporting BigDecimal autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_derby/spec/typecast/boolean_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/boolean_spec' 5 | 6 | describe 'DataObjects::Derby with Boolean' do 7 | it_should_behave_like 'supporting Boolean' 8 | # TODO should we map smallint to boolean for derby ?? 9 | # it_should_behave_like 'supporting Boolean autocasting' 10 | end 11 | -------------------------------------------------------------------------------- /do_derby/spec/typecast/byte_array_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/byte_array_spec' 5 | 6 | describe 'DataObjects::Derby with ByteArray' do 7 | # We need to switch to using parameter binding for this to work with Derby 8 | # it_should_behave_like 'supporting ByteArray' 9 | end 10 | -------------------------------------------------------------------------------- /do_derby/spec/typecast/class_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/class_spec' 5 | 6 | describe 'DataObjects::Derby with Class' do 7 | it_should_behave_like 'supporting Class' 8 | end 9 | -------------------------------------------------------------------------------- /do_derby/spec/typecast/date_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/date_spec' 5 | 6 | describe 'DataObjects::Derby with Date' do 7 | it_should_behave_like 'supporting Date' 8 | it_should_behave_like 'supporting Date autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_derby/spec/typecast/datetime_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/datetime_spec' 5 | 6 | describe 'DataObjects::Derby with DateTime' do 7 | it_should_behave_like 'supporting DateTime' 8 | it_should_behave_like 'supporting DateTime autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_derby/spec/typecast/float_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/float_spec' 5 | 6 | describe 'DataObjects::Derby with Float' do 7 | it_should_behave_like 'supporting Float' 8 | it_should_behave_like 'supporting Float autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_derby/spec/typecast/integer_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/integer_spec' 5 | 6 | describe 'DataObjects::Derby with Integer' do 7 | it_should_behave_like 'supporting Integer' 8 | end 9 | -------------------------------------------------------------------------------- /do_derby/spec/typecast/nil_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/nil_spec' 5 | 6 | describe 'DataObjects::Derby with Nil' do 7 | it_should_behave_like 'supporting Nil' 8 | it_should_behave_like 'supporting writing an Nil' 9 | it_should_behave_like 'supporting Nil autocasting' 10 | end 11 | -------------------------------------------------------------------------------- /do_derby/spec/typecast/other_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/other_spec' 5 | 6 | describe 'DataObjects::H2 with other (unknown) type' do 7 | it_should_behave_like 'supporting other (unknown) type' 8 | end 9 | -------------------------------------------------------------------------------- /do_derby/spec/typecast/range_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/range_spec' 5 | 6 | describe 'DataObjects::Derby with Range' do 7 | it_should_behave_like 'supporting Range' 8 | end 9 | -------------------------------------------------------------------------------- /do_derby/spec/typecast/string_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/string_spec' 5 | 6 | describe 'DataObjects::Derby with String' do 7 | it_should_behave_like 'supporting String' 8 | end 9 | -------------------------------------------------------------------------------- /do_derby/spec/typecast/time_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/time_spec' 5 | 6 | describe 'DataObjects::Derby with Time' do 7 | it_should_behave_like 'supporting Time' 8 | end 9 | -------------------------------------------------------------------------------- /do_derby/tasks/compile.rake: -------------------------------------------------------------------------------- 1 | begin 2 | gem 'rake-compiler', '~>0.7' 3 | require 'rake/javaextensiontask' 4 | 5 | def gemspec 6 | @clean_gemspec ||= Gem::Specification::load(File.expand_path('../../do_derby.gemspec', __FILE__)) 7 | end 8 | 9 | Rake::JavaExtensionTask.new('do_derby', gemspec) do |ext| 10 | ext.ext_dir = 'ext-java/src/main/java' 11 | ext.lib_dir = 'lib/do_derby' 12 | ext.debug = ENV.has_key?('DO_JAVA_DEBUG') && ENV['DO_JAVA_DEBUG'] 13 | ext.classpath = '../do_jdbc/lib/do_jdbc_internal.jar' 14 | end 15 | 16 | # do_derby is only available for JRuby: the normal behaviour of rake-compiler 17 | # is to only chain 'compile:PLATFORM' tasks to 'compile' where PLATFORM is the 18 | # platform of the current interpreter (i.e. 'compile:java' to 'compile' only 19 | # if running on JRuby). However, we always want to compile for Java, even if 20 | # running from MRI. 21 | task 'compile:do_derby' => ['compile:do_derby:java'] 22 | task 'compile' => ['compile:java'] 23 | 24 | rescue LoadError 25 | warn "To compile, install rake-compiler (gem install rake-compiler)" 26 | end 27 | -------------------------------------------------------------------------------- /do_derby/tasks/release.rake: -------------------------------------------------------------------------------- 1 | desc 'Builds all gems (native, binaries for JRuby and Windows)' 2 | task :build_all do 3 | `rake clean` 4 | `rake java gem` 5 | end 6 | 7 | desc 'Release all gems (native, binaries for JRuby and Windows)' 8 | task :release_all => :build_all do 9 | Dir["pkg/do_derby-#{DataObjects::Derby::VERSION}*.gem"].each do |gem_path| 10 | command = "gem push #{gem_path}" 11 | puts "Executing #{command.inspect}:" 12 | sh command 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /do_derby/tasks/spec.rake: -------------------------------------------------------------------------------- 1 | require 'rspec/core/rake_task' 2 | 3 | RSpec::Core::RakeTask.new(:spec => [:clean, :compile]) do |spec| 4 | spec.pattern = './spec/**/*_spec.rb' 5 | end 6 | 7 | RSpec::Core::RakeTask.new(:rcov => [:clean, :compile]) do |rcov| 8 | rcov.pattern = "./spec/**/*_spec.rb" 9 | rcov.rcov = true 10 | rcov.rcov_opts = File.read('spec/rcov.opts').split(/\s+/) 11 | end 12 | -------------------------------------------------------------------------------- /do_h2/.gitignore: -------------------------------------------------------------------------------- 1 | mem.properties 2 | mem.script 3 | test.db.data.db 4 | test.db.index.db 5 | -------------------------------------------------------------------------------- /do_h2/.rspec: -------------------------------------------------------------------------------- 1 | --format documentation 2 | --colour 3 | -------------------------------------------------------------------------------- /do_h2/Gemfile: -------------------------------------------------------------------------------- 1 | source :rubygems 2 | 3 | path '../' 4 | 5 | gemspec 6 | 7 | group :development do # Development dependencies (as in the gemspec) 8 | gem 'rake' 9 | end 10 | -------------------------------------------------------------------------------- /do_h2/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008 - 2011 Alex Coles, Ikonoklastik Productions 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /do_h2/Rakefile: -------------------------------------------------------------------------------- 1 | require 'pathname' 2 | require 'rubygems' 3 | require 'bundler' 4 | require 'rubygems/package_task' 5 | Bundler::GemHelper.install_tasks 6 | 7 | require 'rake' 8 | require 'rake/clean' 9 | 10 | ROOT = Pathname(__FILE__).dirname.expand_path 11 | 12 | require ROOT + 'lib/do_h2/version' 13 | 14 | JRUBY = RUBY_PLATFORM =~ /java/ 15 | IRONRUBY = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ironruby' 16 | WINDOWS = Gem.win_platform? || (JRUBY && ENV_JAVA['os.name'] =~ /windows/i) 17 | SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS']) 18 | 19 | CLEAN.include(%w[ {tmp,pkg}/ **/*.{o,so,bundle,jar,log,a,gem,dSYM,obj,pdb,exp,DS_Store,rbc,db} ext-java/target ]) 20 | 21 | 22 | Rake::Task['build'].clear_actions if Rake::Task.task_defined?('build') 23 | task :build => [ :java, :gem ] 24 | 25 | FileList['tasks/**/*.rake'].each { |task| import task } 26 | -------------------------------------------------------------------------------- /do_h2/buildfile: -------------------------------------------------------------------------------- 1 | # Apache Buildr buildfile for do_h2 2 | # see http://incubator.apache.org/buildr/ for more information on Apache Buildr 3 | require 'buildr' 4 | require 'pathname' 5 | 6 | VERSION_NUMBER = '1.0' 7 | JDBC_SUPPORT = ['data_objects:jdbc:jar:1.0'] 8 | TARGET_DIR = 'pkg/classes' 9 | repositories.remote << 'http://www.ibiblio.org/maven2/' 10 | 11 | define 'do_h2' do 12 | project.version = VERSION_NUMBER 13 | project.group = 'data_objects.rb' 14 | 15 | manifest['Copyright'] = 'Alex Coles (C) 2008-2011' 16 | 17 | compile.using :target => '1.5', :lint => 'all', :deprecation => 'true' 18 | 19 | define 'ext-java' do 20 | package(:jar).clean.include(TARGET_DIR) 21 | 22 | jdbc_support_jar = file('../../do_jdbc/lib/do_jdbc_internal.jar') 23 | jdbc_support = artifact('data_objects:jdbc:jar:1.0').from(jdbc_support_jar) 24 | 25 | compile.into(TARGET_DIR).with(JDBC_SUPPORT) 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /do_h2/ext-java/src/main/java/do_h2/DoH2Service.java: -------------------------------------------------------------------------------- 1 | package do_h2; 2 | 3 | import data_objects.drivers.AbstractDataObjectsService; 4 | import data_objects.drivers.DriverDefinition; 5 | 6 | public class DoH2Service extends AbstractDataObjectsService { 7 | 8 | private final static DriverDefinition driver = new H2DriverDefinition(); 9 | 10 | /** 11 | * 12 | * @return 13 | */ 14 | @Override 15 | public DriverDefinition getDriverDefinition() { 16 | return driver; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /do_h2/ext-java/src/main/java/do_h2/H2DriverDefinition.java: -------------------------------------------------------------------------------- 1 | package do_h2; 2 | 3 | import data_objects.drivers.AbstractDriverDefinition; 4 | 5 | public class H2DriverDefinition extends AbstractDriverDefinition { 6 | public final static String URI_SCHEME = "h2"; 7 | public final static String RUBY_MODULE_NAME = "H2"; 8 | public final static String JDBC_DRIVER = "org.h2.Driver"; 9 | 10 | /** 11 | * 12 | */ 13 | public H2DriverDefinition(){ 14 | super(URI_SCHEME, RUBY_MODULE_NAME, JDBC_DRIVER); 15 | } 16 | 17 | /** 18 | * 19 | * @return 20 | */ 21 | @Override 22 | public boolean supportsJdbcGeneratedKeys() 23 | { 24 | return true; 25 | } 26 | 27 | /** 28 | * 29 | * @return 30 | */ 31 | @Override 32 | public boolean supportsJdbcScrollableResultSets() 33 | { 34 | return true; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /do_h2/lib/do_h2.rb: -------------------------------------------------------------------------------- 1 | require 'data_objects' 2 | 3 | if RUBY_PLATFORM =~ /java/ 4 | require 'do_jdbc' 5 | require 'java' 6 | 7 | module DataObjects 8 | module H2 9 | JDBC_DRIVER = 'org.h2.Driver' 10 | end 11 | end 12 | 13 | begin 14 | java.lang.Thread.currentThread.getContextClassLoader().loadClass(DataObjects::H2::JDBC_DRIVER, true) 15 | rescue java.lang.ClassNotFoundException 16 | require 'jdbc/h2' # the JDBC driver, packaged as a gem 17 | Jdbc::H2.load_driver if Jdbc::H2.respond_to?(:load_driver) 18 | end 19 | 20 | require 'do_h2/do_h2' # the Java extension for this DO driver 21 | 22 | # Another way of loading the JDBC Class. This seems to be more reliable 23 | # than Class.forName() within the data_objects.Connection Java class, 24 | # which is currently not working as expected. 25 | java_import DataObjects::H2::JDBC_DRIVER 26 | 27 | else 28 | warn "do_h2 is only for use with JRuby" 29 | end 30 | -------------------------------------------------------------------------------- /do_h2/lib/do_h2/version.rb: -------------------------------------------------------------------------------- 1 | module DataObjects 2 | module H2 3 | VERSION = '0.10.17' 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /do_h2/spec/command_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/command_spec' 5 | 6 | describe DataObjects::H2::Command do 7 | it_should_behave_like 'a Command' 8 | # it_should_behave_like 'a Command with async' 9 | end 10 | -------------------------------------------------------------------------------- /do_h2/spec/connection_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/connection_spec' 5 | 6 | describe DataObjects::H2::Connection do 7 | 8 | before :all do 9 | @driver = 'h2' 10 | @user = '' 11 | @password = '' 12 | @host = '' 13 | @port = '' 14 | @database = "#{File.expand_path(File.dirname(__FILE__))}/test.db" 15 | end 16 | 17 | it_should_behave_like 'a Connection' 18 | #it_should_behave_like 'a Connection with authentication support' 19 | it_should_behave_like 'a Connection with JDBC URL support' 20 | it_should_behave_like 'a Connection via JDNI' 21 | end 22 | -------------------------------------------------------------------------------- /do_h2/spec/encoding_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/encoding_spec' 5 | 6 | describe DataObjects::H2::Connection do 7 | #it_should_behave_like 'a driver supporting different encodings' 8 | end 9 | -------------------------------------------------------------------------------- /do_h2/spec/rcov.opts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datamapper/do/16564e6dba587e92e41aba376b46ef765f3bffea/do_h2/spec/rcov.opts -------------------------------------------------------------------------------- /do_h2/spec/reader_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/reader_spec' 5 | 6 | describe DataObjects::H2::Reader do 7 | it_should_behave_like 'a Reader' 8 | end 9 | -------------------------------------------------------------------------------- /do_h2/spec/result_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/result_spec' 5 | 6 | # splitting the descibe into two separate declaration avoids 7 | # concurrent execution of the "it_should_behave_like ....." 8 | # needed by some databases (sqlite3) 9 | 10 | describe DataObjects::H2::Result do 11 | it_should_behave_like 'a Result' 12 | end 13 | 14 | describe DataObjects::H2::Result do 15 | it_should_behave_like 'a Result which returns inserted key with sequences' 16 | end 17 | -------------------------------------------------------------------------------- /do_h2/spec/typecast/array_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/array_spec' 5 | 6 | describe 'DataObjects::H2 with Array' do 7 | it_should_behave_like 'supporting Array' 8 | end 9 | -------------------------------------------------------------------------------- /do_h2/spec/typecast/bigdecimal_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/bigdecimal_spec' 5 | 6 | describe 'DataObjects::H2 with BigDecimal' do 7 | it_should_behave_like 'supporting BigDecimal' 8 | it_should_behave_like 'supporting BigDecimal autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_h2/spec/typecast/boolean_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/boolean_spec' 5 | 6 | describe 'DataObjects::H2 with Boolean' do 7 | it_should_behave_like 'supporting Boolean' 8 | it_should_behave_like 'supporting Boolean autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_h2/spec/typecast/byte_array_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/byte_array_spec' 5 | 6 | describe 'DataObjects::H2 with ByteArray' do 7 | # We need to switch to using parameter binding for this to work with H2 8 | # it_should_behave_like 'supporting ByteArray' 9 | end 10 | -------------------------------------------------------------------------------- /do_h2/spec/typecast/class_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/class_spec' 5 | 6 | describe 'DataObjects::H2 with Class' do 7 | it_should_behave_like 'supporting Class' 8 | end 9 | -------------------------------------------------------------------------------- /do_h2/spec/typecast/date_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/date_spec' 5 | 6 | describe 'DataObjects::H2 with Date' do 7 | it_should_behave_like 'supporting Date' 8 | it_should_behave_like 'supporting Date autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_h2/spec/typecast/datetime_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/datetime_spec' 5 | 6 | describe 'DataObjects::H2 with DateTime' do 7 | it_should_behave_like 'supporting DateTime' 8 | it_should_behave_like 'supporting DateTime autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_h2/spec/typecast/float_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/float_spec' 5 | 6 | describe 'DataObjects::H2 with Float' do 7 | it_should_behave_like 'supporting Float' 8 | it_should_behave_like 'supporting Float autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_h2/spec/typecast/integer_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/integer_spec' 5 | 6 | describe 'DataObjects::H2 with Integer' do 7 | it_should_behave_like 'supporting Integer' 8 | end 9 | -------------------------------------------------------------------------------- /do_h2/spec/typecast/nil_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/nil_spec' 5 | 6 | describe 'DataObjects::H2 with Nil' do 7 | it_should_behave_like 'supporting Nil' 8 | it_should_behave_like 'supporting writing an Nil' 9 | it_should_behave_like 'supporting Nil autocasting' 10 | end 11 | -------------------------------------------------------------------------------- /do_h2/spec/typecast/other_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/other_spec' 5 | 6 | describe 'DataObjects::H2 with other (unknown) type' do 7 | it_should_behave_like 'supporting other (unknown) type' 8 | end 9 | -------------------------------------------------------------------------------- /do_h2/spec/typecast/range_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/range_spec' 5 | 6 | describe 'DataObjects::H2 with Range' do 7 | it_should_behave_like 'supporting Range' 8 | end 9 | -------------------------------------------------------------------------------- /do_h2/spec/typecast/string_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/string_spec' 5 | 6 | describe 'DataObjects::H2 with String' do 7 | it_should_behave_like 'supporting String' 8 | end 9 | -------------------------------------------------------------------------------- /do_h2/spec/typecast/time_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/time_spec' 5 | 6 | describe 'DataObjects::H2 with Time' do 7 | it_should_behave_like 'supporting Time' 8 | end 9 | -------------------------------------------------------------------------------- /do_h2/tasks/compile.rake: -------------------------------------------------------------------------------- 1 | begin 2 | gem 'rake-compiler', '~>0.7' 3 | require 'rake/javaextensiontask' 4 | 5 | def gemspec 6 | @clean_gemspec ||= Gem::Specification::load(File.expand_path('../../do_h2.gemspec', __FILE__)) 7 | end 8 | 9 | Rake::JavaExtensionTask.new('do_h2', gemspec) do |ext| 10 | ext.ext_dir = 'ext-java/src/main/java' 11 | ext.lib_dir = 'lib/do_h2' 12 | ext.debug = ENV.has_key?('DO_JAVA_DEBUG') && ENV['DO_JAVA_DEBUG'] 13 | ext.classpath = '../do_jdbc/lib/do_jdbc_internal.jar' 14 | end 15 | 16 | # do_h2 is only available for JRuby: the normal behaviour of rake-compiler 17 | # is to only chain 'compile:PLATFORM' tasks to 'compile' where PLATFORM is 18 | # the platform of the current interpreter (i.e. 'compile:java' to 'compile' 19 | # only if running on JRuby). However, we always want to compile for Java, 20 | # even if running from MRI. 21 | task 'compile:do_h2' => ['compile:do_h2:java'] 22 | task 'compile' => ['compile:java'] 23 | 24 | rescue LoadError 25 | warn "To compile, install rake-compiler (gem install rake-compiler)" 26 | end 27 | -------------------------------------------------------------------------------- /do_h2/tasks/release.rake: -------------------------------------------------------------------------------- 1 | desc 'Builds all gems (native, binaries for JRuby and Windows)' 2 | task :build_all do 3 | `rake clean` 4 | `rake java gem` 5 | end 6 | 7 | desc 'Release all gems (native, binaries for JRuby and Windows)' 8 | task :release_all => :build_all do 9 | Dir["pkg/do_h2-#{DataObjects::H2::VERSION}*.gem"].each do |gem_path| 10 | command = "gem push #{gem_path}" 11 | puts "Executing #{command.inspect}:" 12 | sh command 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /do_h2/tasks/spec.rake: -------------------------------------------------------------------------------- 1 | require 'rspec/core/rake_task' 2 | 3 | RSpec::Core::RakeTask.new(:spec => [:clean, :compile]) do |spec| 4 | spec.pattern = './spec/**/*_spec.rb' 5 | end 6 | 7 | RSpec::Core::RakeTask.new(:rcov => [:clean, :compile]) do |rcov| 8 | rcov.pattern = "./spec/**/*_spec.rb" 9 | rcov.rcov = true 10 | rcov.rcov_opts = File.read('spec/rcov.opts').split(/\s+/) 11 | end 12 | -------------------------------------------------------------------------------- /do_hsqldb/.gitignore: -------------------------------------------------------------------------------- 1 | mem.* 2 | spec/test.db.properties 3 | spec/test.db.log 4 | spec/test.db.data 5 | -------------------------------------------------------------------------------- /do_hsqldb/.rspec: -------------------------------------------------------------------------------- 1 | --format documentation 2 | --colour 3 | -------------------------------------------------------------------------------- /do_hsqldb/Gemfile: -------------------------------------------------------------------------------- 1 | source :rubygems 2 | 3 | path '../' 4 | 5 | gemspec 6 | 7 | group :development do # Development dependencies (as in the gemspec) 8 | gem 'rake' 9 | end 10 | -------------------------------------------------------------------------------- /do_hsqldb/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008 - 2011 Alex Coles, Ikonoklastik Productions 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /do_hsqldb/Rakefile: -------------------------------------------------------------------------------- 1 | require 'pathname' 2 | require 'rubygems' 3 | require 'bundler' 4 | require 'rubygems/package_task' 5 | Bundler::GemHelper.install_tasks 6 | 7 | require 'rake' 8 | require 'rake/clean' 9 | 10 | ROOT = Pathname(__FILE__).dirname.expand_path 11 | 12 | require ROOT + 'lib/do_hsqldb/version' 13 | 14 | JRUBY = RUBY_PLATFORM =~ /java/ 15 | IRONRUBY = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ironruby' 16 | WINDOWS = Gem.win_platform? || (JRUBY && ENV_JAVA['os.name'] =~ /windows/i) 17 | SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS']) 18 | 19 | CLEAN.include(%w[ {tmp,pkg}/ **/*.{o,so,bundle,jar,log,a,gem,dSYM,obj,pdb,exp,DS_Store,rbc,db} ext-java/target ]) 20 | 21 | 22 | Rake::Task['build'].clear_actions if Rake::Task.task_defined?('build') 23 | task :build => [ :java, :gem ] 24 | 25 | FileList['tasks/**/*.rake'].each { |task| import task } 26 | -------------------------------------------------------------------------------- /do_hsqldb/buildfile: -------------------------------------------------------------------------------- 1 | # Apache Buildr buildfile for do_hsqldb 2 | # see http://incubator.apache.org/buildr/ for more information on Apache Buildr 3 | require 'buildr' 4 | require 'pathname' 5 | 6 | VERSION_NUMBER = '1.0' 7 | JDBC_SUPPORT = ['data_objects:jdbc:jar:1.0'] 8 | TARGET_DIR = 'pkg/classes' 9 | repositories.remote << 'http://www.ibiblio.org/maven2/' 10 | 11 | define 'do_hsqldb' do 12 | project.version = VERSION_NUMBER 13 | project.group = 'data_objects.rb' 14 | 15 | manifest['Copyright'] = 'Alex Coles (C) 2008-2011' 16 | 17 | compile.using :target => '1.5', :lint => 'all', :deprecation => 'true' 18 | 19 | define 'ext-java' do 20 | package(:jar).clean.include(TARGET_DIR) 21 | 22 | jdbc_support_jar = file('../../do_jdbc/lib/do_jdbc_internal.jar') 23 | jdbc_support = artifact('data_objects:jdbc:jar:1.0').from(jdbc_support_jar) 24 | 25 | compile.into(TARGET_DIR).with(JDBC_SUPPORT) 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /do_hsqldb/ext-java/src/main/java/do_hsqldb/DoHsqldbService.java: -------------------------------------------------------------------------------- 1 | package do_hsqldb; 2 | 3 | import data_objects.drivers.AbstractDataObjectsService; 4 | import data_objects.drivers.DriverDefinition; 5 | 6 | public class DoHsqldbService extends AbstractDataObjectsService { 7 | 8 | private final static DriverDefinition driver = new HsqldbDriverDefinition(); 9 | 10 | /** 11 | * 12 | * @return 13 | */ 14 | @Override 15 | public DriverDefinition getDriverDefinition() { 16 | return driver; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /do_hsqldb/lib/do_hsqldb.rb: -------------------------------------------------------------------------------- 1 | require 'data_objects' 2 | 3 | if RUBY_PLATFORM =~ /java/ 4 | require 'do_jdbc' 5 | require 'java' 6 | 7 | module DataObjects 8 | module Hsqldb 9 | JDBC_DRIVER = 'org.hsqldb.jdbcDriver' 10 | end 11 | end 12 | 13 | begin 14 | java.lang.Thread.currentThread.getContextClassLoader().loadClass(DataObjects::Hsqldb::JDBC_DRIVER, true) 15 | rescue java.lang.ClassNotFoundException 16 | require 'jdbc/hsqldb' # the JDBC driver, packaged as a gem 17 | Jdbc::HSQLDB.load_driver if Jdbc::HSQLDB.respond_to?(:load_driver) 18 | end 19 | require 'do_hsqldb/do_hsqldb' # the Java extension for this DO driver 20 | 21 | # Another way of loading the JDBC Class. This seems to be more reliable 22 | # than Class.forName() within the data_objects.Connection Java class, 23 | # which is currently not working as expected. 24 | java_import(DataObjects::Hsqldb::JDBC_DRIVER) { 'JdbcDriver' } 25 | 26 | else 27 | warn "do_hsqldb is only for use with JRuby" 28 | end 29 | -------------------------------------------------------------------------------- /do_hsqldb/lib/do_hsqldb/version.rb: -------------------------------------------------------------------------------- 1 | module DataObjects 2 | module Hsqldb 3 | VERSION = '0.10.17' 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /do_hsqldb/spec/command_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/command_spec' 5 | 6 | describe DataObjects::Hsqldb::Command do 7 | it_should_behave_like 'a Command' 8 | # it_should_behave_like 'a Command with async' 9 | end 10 | -------------------------------------------------------------------------------- /do_hsqldb/spec/connection_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/connection_spec' 5 | 6 | describe DataObjects::Hsqldb::Connection do 7 | 8 | before :all do 9 | @driver = 'hsqldb' 10 | @user = '' 11 | @password = '' 12 | @host = '' 13 | @port = '' 14 | @database = "#{File.expand_path(File.dirname(__FILE__))}/test.db" 15 | end 16 | 17 | it_should_behave_like 'a Connection' 18 | #it_should_behave_like 'a Connection with authentication support' 19 | it_should_behave_like 'a Connection with JDBC URL support' 20 | it_should_behave_like 'a Connection via JDNI' 21 | end 22 | -------------------------------------------------------------------------------- /do_hsqldb/spec/encoding_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/encoding_spec' 5 | 6 | describe DataObjects::Hsqldb::Connection do 7 | # it_should_behave_like 'a driver supporting different encodings' 8 | end 9 | -------------------------------------------------------------------------------- /do_hsqldb/spec/rcov.opts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datamapper/do/16564e6dba587e92e41aba376b46ef765f3bffea/do_hsqldb/spec/rcov.opts -------------------------------------------------------------------------------- /do_hsqldb/spec/reader_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/reader_spec' 5 | 6 | describe DataObjects::Hsqldb::Reader do 7 | it_should_behave_like 'a Reader' 8 | end 9 | -------------------------------------------------------------------------------- /do_hsqldb/spec/result_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/result_spec' 5 | 6 | # splitting the descibe into two separate declaration avoids 7 | # concurrent execution of the "it_should_behave_like ....." 8 | # needed by some databases (sqlite3) 9 | 10 | describe DataObjects::Hsqldb::Result do 11 | it_should_behave_like 'a Result' 12 | end 13 | 14 | describe DataObjects::Hsqldb::Result do 15 | it_should_behave_like 'a Result which returns inserted key with sequences' 16 | end 17 | -------------------------------------------------------------------------------- /do_hsqldb/spec/test.db.script: -------------------------------------------------------------------------------- 1 | CREATE SCHEMA PUBLIC AUTHORIZATION DBA 2 | CREATE USER SA PASSWORD "" 3 | GRANT DBA TO SA 4 | SET WRITE_DELAY 20 5 | -------------------------------------------------------------------------------- /do_hsqldb/spec/typecast/array_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/array_spec' 5 | 6 | describe 'DataObjects::Hsqldb with Array' do 7 | it_should_behave_like 'supporting Array' 8 | end 9 | -------------------------------------------------------------------------------- /do_hsqldb/spec/typecast/bigdecimal_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/bigdecimal_spec' 5 | 6 | describe 'DataObjects::Hsqldb with BigDecimal' do 7 | it_should_behave_like 'supporting BigDecimal' 8 | it_should_behave_like 'supporting BigDecimal autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_hsqldb/spec/typecast/boolean_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/boolean_spec' 5 | 6 | describe 'DataObjects::Hsqldb with Boolean' do 7 | it_should_behave_like 'supporting Boolean' 8 | it_should_behave_like 'supporting Boolean autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_hsqldb/spec/typecast/byte_array_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/byte_array_spec' 5 | 6 | describe 'DataObjects::Hsqldb with ByteArray' do 7 | # We need to switch to using parameter binding for this to work with Hsqldb 8 | # it_should_behave_like 'supporting ByteArray' 9 | end 10 | -------------------------------------------------------------------------------- /do_hsqldb/spec/typecast/class_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/class_spec' 5 | 6 | describe 'DataObjects::Hsqldb with Class' do 7 | it_should_behave_like 'supporting Class' 8 | end 9 | -------------------------------------------------------------------------------- /do_hsqldb/spec/typecast/date_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/date_spec' 5 | 6 | describe 'DataObjects::Hsqldb with Date' do 7 | it_should_behave_like 'supporting Date' 8 | it_should_behave_like 'supporting Date autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_hsqldb/spec/typecast/datetime_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/datetime_spec' 5 | 6 | describe 'DataObjects::Hsqldb with DateTime' do 7 | it_should_behave_like 'supporting DateTime' 8 | it_should_behave_like 'supporting DateTime autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_hsqldb/spec/typecast/float_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/float_spec' 5 | 6 | describe 'DataObjects::Hsqldb with Float' do 7 | it_should_behave_like 'supporting Float' 8 | it_should_behave_like 'supporting Float autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_hsqldb/spec/typecast/integer_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/integer_spec' 5 | 6 | describe 'DataObjects::Hsqldb with Integer' do 7 | it_should_behave_like 'supporting Integer' 8 | end 9 | -------------------------------------------------------------------------------- /do_hsqldb/spec/typecast/nil_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/nil_spec' 5 | 6 | describe 'DataObjects::Hsqldb with Nil' do 7 | it_should_behave_like 'supporting Nil' 8 | it_should_behave_like 'supporting writing an Nil' 9 | it_should_behave_like 'supporting Nil autocasting' 10 | end 11 | -------------------------------------------------------------------------------- /do_hsqldb/spec/typecast/other_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/other_spec' 5 | 6 | describe 'DataObjects::H2 with other (unknown) type' do 7 | it_should_behave_like 'supporting other (unknown) type' 8 | end 9 | -------------------------------------------------------------------------------- /do_hsqldb/spec/typecast/range_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/range_spec' 5 | 6 | describe 'DataObjects::Hsqldb with Range' do 7 | it_should_behave_like 'supporting Range' 8 | end 9 | -------------------------------------------------------------------------------- /do_hsqldb/spec/typecast/string_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/string_spec' 5 | 6 | describe 'DataObjects::Hsqldb with String' do 7 | it_should_behave_like 'supporting String' 8 | end 9 | -------------------------------------------------------------------------------- /do_hsqldb/spec/typecast/time_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/time_spec' 5 | 6 | describe 'DataObjects::Hsqldb with Time' do 7 | it_should_behave_like 'supporting Time' 8 | end 9 | -------------------------------------------------------------------------------- /do_hsqldb/tasks/compile.rake: -------------------------------------------------------------------------------- 1 | begin 2 | gem 'rake-compiler', '~>0.7' 3 | require 'rake/javaextensiontask' 4 | 5 | def gemspec 6 | @clean_gemspec ||= Gem::Specification::load(File.expand_path('../../do_hsqldb.gemspec', __FILE__)) 7 | end 8 | 9 | Rake::JavaExtensionTask.new('do_hsqldb', gemspec) do |ext| 10 | ext.ext_dir = 'ext-java/src/main/java' 11 | ext.lib_dir = 'lib/do_hsqldb' 12 | ext.debug = ENV.has_key?('DO_JAVA_DEBUG') && ENV['DO_JAVA_DEBUG'] 13 | ext.classpath = '../do_jdbc/lib/do_jdbc_internal.jar' 14 | end 15 | 16 | # do_hsqldb is only available for JRuby: the normal behaviour of rake-compiler 17 | # is to only chain 'compile:PLATFORM' tasks to 'compile' where PLATFORM is the 18 | # platform of the current interpreter (i.e. 'compile:java' to 'compile' only 19 | # if running on JRuby). However, we always want to compile for Java, even if 20 | # running from MRI. 21 | task 'compile:do_hsqldb' => ['compile:do_hsqldb:java'] 22 | task 'compile' => ['compile:java'] 23 | 24 | rescue LoadError 25 | warn "To compile, install rake-compiler (gem install rake-compiler)" 26 | end 27 | -------------------------------------------------------------------------------- /do_hsqldb/tasks/release.rake: -------------------------------------------------------------------------------- 1 | desc 'Builds all gems (native, binaries for JRuby and Windows)' 2 | task :build_all do 3 | `rake clean` 4 | `rake java gem` 5 | end 6 | 7 | desc 'Release all gems (native, binaries for JRuby and Windows)' 8 | task :release_all => :build_all do 9 | Dir["pkg/do_hsqldb-#{DataObjects::Hsqldb::VERSION}*.gem"].each do |gem_path| 10 | command = "gem push #{gem_path}" 11 | puts "Executing #{command.inspect}:" 12 | sh command 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /do_hsqldb/tasks/spec.rake: -------------------------------------------------------------------------------- 1 | require 'rspec/core/rake_task' 2 | 3 | RSpec::Core::RakeTask.new(:spec => [:clean, :compile]) do |spec| 4 | spec.pattern = './spec/**/*_spec.rb' 5 | end 6 | 7 | RSpec::Core::RakeTask.new(:rcov => [:clean, :compile]) do |rcov| 8 | rcov.pattern = "./spec/**/*_spec.rb" 9 | rcov.rcov = true 10 | rcov.rcov_opts = File.read('spec/rcov.opts').split(/\s+/) 11 | end 12 | -------------------------------------------------------------------------------- /do_jdbc-tools/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.dataobjects 6 | dataobjects 7 | 0.10.17 8 | 9 | do_jdbc-tools 10 | do_jdbc-tools 11 | build tools for do_jdbc 12 | 13 | 14 | 15 | de.saumya.mojo 16 | rails-maven-plugin 17 | 18 | true 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /do_jdbc-tools/src/main/resources/data_objects/LICENSE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datamapper/do/16564e6dba587e92e41aba376b46ef765f3bffea/do_jdbc-tools/src/main/resources/data_objects/LICENSE.txt -------------------------------------------------------------------------------- /do_jdbc/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.log 3 | ./doc 4 | ./cov 5 | build 6 | dist 7 | lib/*.jar 8 | lib/do_jdbc/*.jar 9 | pkg/* 10 | -------------------------------------------------------------------------------- /do_jdbc/Gemfile: -------------------------------------------------------------------------------- 1 | source :rubygems 2 | 3 | path '../' 4 | 5 | gemspec 6 | 7 | group :development do # Development dependencies (as in the gemspec) 8 | gem 'rake' 9 | end 10 | -------------------------------------------------------------------------------- /do_jdbc/Rakefile: -------------------------------------------------------------------------------- 1 | require 'pathname' 2 | require 'rubygems' 3 | require 'bundler' 4 | require 'rubygems/package_task' 5 | Bundler::GemHelper.install_tasks 6 | 7 | require 'rake' 8 | require 'rake/clean' 9 | 10 | ROOT = Pathname(__FILE__).dirname.expand_path 11 | 12 | require ROOT + 'lib/do_jdbc/version' 13 | 14 | JRUBY = RUBY_PLATFORM =~ /java/ 15 | IRONRUBY = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ironruby' 16 | WINDOWS = Gem.win_platform? || (JRUBY && ENV_JAVA['os.name'] =~ /windows/i) 17 | SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS']) 18 | 19 | CLEAN.include(%w[ {tmp,pkg}/ **/*.{o,so,bundle,jar,log,a,gem,dSYM,obj,pdb,exp,DS_Store,rbc,db} ext-java/target ]) 20 | 21 | task :default do 22 | # do nothing 23 | end 24 | 25 | 26 | Rake::Task['build'].clear_actions if Rake::Task.task_defined?('build') 27 | task :build => [ :java, :gem ] 28 | 29 | FileList['tasks/**/*.rake'].each { |task| import task } 30 | -------------------------------------------------------------------------------- /do_jdbc/lib/do_jdbc.rb: -------------------------------------------------------------------------------- 1 | if RUBY_PLATFORM =~ /java/ 2 | require 'java' 3 | require 'bigdecimal' 4 | require 'do_jdbc_internal' 5 | require 'data_objects' 6 | else 7 | warn "do_jdbc is for use with JRuby only" 8 | end 9 | -------------------------------------------------------------------------------- /do_jdbc/lib/do_jdbc/version.rb: -------------------------------------------------------------------------------- 1 | module DataObjects 2 | module Jdbc 3 | VERSION = '0.10.17' 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /do_jdbc/src/main/java/data_objects/DORubyObject.java: -------------------------------------------------------------------------------- 1 | package data_objects; 2 | 3 | import org.jruby.Ruby; 4 | import org.jruby.RubyClass; 5 | import org.jruby.RubyObject; 6 | import org.jruby.RubyObjectAdapter; 7 | import org.jruby.javasupport.JavaEmbedUtils; 8 | 9 | import data_objects.drivers.DriverDefinition; 10 | 11 | @SuppressWarnings("serial") 12 | abstract public class DORubyObject extends RubyObject { 13 | 14 | final DriverDefinition driver; 15 | 16 | final RubyObjectAdapter api; 17 | 18 | /** 19 | * 20 | * @param runtime 21 | * @param clazz 22 | */ 23 | DORubyObject(Ruby runtime, RubyClass clazz) { 24 | super(runtime, clazz); 25 | this.driver = (DriverDefinition) JavaEmbedUtils.rubyToJava(clazz 26 | .getInstanceVariable("@__driver")); 27 | this.api = driver.getObjectAdapter(); 28 | } 29 | 30 | /** 31 | * 32 | * @param clazz 33 | * @param runtime 34 | * @param driver 35 | */ 36 | static void setDriverDefinition(RubyClass clazz, Ruby runtime, DriverDefinition driver) { 37 | clazz.setInstanceVariable("@__driver", JavaEmbedUtils.javaToRuby( 38 | runtime, driver)); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /do_jdbc/src/main/java/data_objects/DataObjects.java: -------------------------------------------------------------------------------- 1 | package data_objects; 2 | 3 | /** 4 | * Constants for DataObjects 5 | * 6 | * @author alexbcoles 7 | */ 8 | final public class DataObjects { 9 | 10 | public final static String DATA_OBJECTS_MODULE_NAME = "DataObjects"; 11 | 12 | /** 13 | * Private constructor 14 | */ 15 | private DataObjects(){ 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /do_jdbc/tasks/compile.rake: -------------------------------------------------------------------------------- 1 | begin 2 | gem 'rake-compiler', '~>0.7' 3 | require 'rake/javaextensiontask' 4 | 5 | def gemspec 6 | @clean_gemspec ||= Gem::Specification::load(File.expand_path('../../do_jdbc.gemspec', __FILE__)) 7 | end 8 | 9 | Rake::JavaExtensionTask.new('do_jdbc_internal', gemspec) do |ext| 10 | ext.ext_dir = 'src/main/java' 11 | end 12 | 13 | # do_jdbc is only available for JRuby: the normal behaviour of rake-compiler 14 | # is to only chain 'compile:PLATFORM' tasks to 'compile' where PLATFORM is the 15 | # platform of the current interpreter (i.e. 'compile:java' to 'compile' only 16 | # if running on JRuby). However, we always want to compile for Java, even if 17 | # running from MRI. 18 | task 'compile:do_jdbc_internal' => ['compile:do_jdbc_internal:java'] 19 | task 'compile' => ['compile:java'] 20 | 21 | rescue LoadError 22 | warn "To compile, install rake-compiler (gem install rake-compiler)" 23 | end 24 | -------------------------------------------------------------------------------- /do_jdbc/tasks/release.rake: -------------------------------------------------------------------------------- 1 | desc 'Builds all gems (native, binaries for JRuby and Windows)' 2 | task :build_all do 3 | `rake clean` 4 | `rake java gem` 5 | end 6 | 7 | desc 'Release all gems (native, binaries for JRuby and Windows)' 8 | task :release_all => :build_all do 9 | Dir["pkg/do_jdbc-#{DataObjects::Jdbc::VERSION}*.gem"].each do |gem_path| 10 | command = "gem push #{gem_path}" 11 | puts "Executing #{command.inspect}:" 12 | sh command 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /do_mysql/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datamapper/do/16564e6dba587e92e41aba376b46ef765f3bffea/do_mysql/.gitignore -------------------------------------------------------------------------------- /do_mysql/.rspec: -------------------------------------------------------------------------------- 1 | --format documentation 2 | --colour 3 | -------------------------------------------------------------------------------- /do_mysql/Gemfile: -------------------------------------------------------------------------------- 1 | source :rubygems 2 | 3 | path '../' 4 | 5 | gemspec 6 | 7 | platforms :jruby do 8 | gem 'jdbc-mysql', '>=5.0.4' 9 | gem 'do_jdbc', '0.10.17' 10 | end 11 | 12 | group :development do # Development dependencies (as in the gemspec) 13 | gem 'rake' 14 | end 15 | -------------------------------------------------------------------------------- /do_mysql/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2007 - 2011 Yehuda Katz, Dirkjan Bussink 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /do_mysql/Rakefile: -------------------------------------------------------------------------------- 1 | require 'pathname' 2 | require 'rubygems' 3 | require 'bundler' 4 | require 'rubygems/package_task' 5 | Bundler::GemHelper.install_tasks 6 | 7 | require 'rake' 8 | require 'rake/clean' 9 | 10 | ROOT = Pathname(__FILE__).dirname.expand_path 11 | 12 | require ROOT + 'lib/do_mysql/version' 13 | 14 | JRUBY = RUBY_PLATFORM =~ /java/ 15 | IRONRUBY = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ironruby' 16 | WINDOWS = Gem.win_platform? || (JRUBY && ENV_JAVA['os.name'] =~ /windows/i) 17 | SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS']) 18 | BINARY_VERSION = '5.1.65' 19 | 20 | CLEAN.include(%w[ {tmp,pkg}/ **/*.{o,so,bundle,jar,log,a,gem,dSYM,obj,pdb,exp,DS_Store,rbc,db} ext/do_mysql/Makefile ext-java/target ]) 21 | 22 | 23 | if JRUBY 24 | Rake::Task['build'].clear_actions if Rake::Task.task_defined?('build') 25 | Rake::Task['install'].clear_actions if Rake::Task.task_defined?('install') 26 | task :build => [ :java, :gem ] 27 | task :install do 28 | sh "#{Config::CONFIG['RUBY_INSTALL_NAME']} -S gem install pkg/do_mysql-#{DataObjects::Mysql::VERSION}-java.gem" 29 | end 30 | end 31 | 32 | FileList['tasks/**/*.rake'].each { |task| import task } 33 | -------------------------------------------------------------------------------- /do_mysql/buildfile: -------------------------------------------------------------------------------- 1 | # Apache Buildr buildfile for do_mysql 2 | # see http://incubator.apache.org/buildr/ for more information on Apache Buildr 3 | require 'buildr' 4 | require 'pathname' 5 | 6 | VERSION_NUMBER = '1.0' 7 | JDBC_SUPPORT = ['data_objects:jdbc:jar:1.0'] 8 | TARGET_DIR = 'pkg/classes' 9 | repositories.remote << 'http://www.ibiblio.org/maven2/' 10 | 11 | define 'do_mysql' do 12 | project.version = VERSION_NUMBER 13 | project.group = 'data_objects.rb' 14 | 15 | manifest['Copyright'] = 'Alex Coles (C) 2008-2011' 16 | 17 | compile.using :target => '1.5', :lint => 'all', :deprecation => 'true' 18 | 19 | define 'ext-java' do 20 | package(:jar).clean.include(TARGET_DIR) 21 | 22 | jdbc_support_jar = file('../../do_jdbc/lib/do_jdbc_internal.jar') 23 | jdbc_support = artifact('data_objects:jdbc:jar:1.0').from(jdbc_support_jar) 24 | 25 | compile.into(TARGET_DIR).with(JDBC_SUPPORT) 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /do_mysql/ext-java/src/main/java/do_mysql/DoMysqlService.java: -------------------------------------------------------------------------------- 1 | package do_mysql; 2 | 3 | import data_objects.drivers.AbstractDataObjectsService; 4 | import data_objects.drivers.DriverDefinition; 5 | 6 | public class DoMysqlService extends AbstractDataObjectsService { 7 | 8 | private final static DriverDefinition driver = new MySqlDriverDefinition(); 9 | 10 | /** 11 | * 12 | * @return 13 | */ 14 | @Override 15 | public DriverDefinition getDriverDefinition() { 16 | return driver; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /do_mysql/ext/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | mkmf.log 3 | -------------------------------------------------------------------------------- /do_mysql/ext/do_mysql/compat.h: -------------------------------------------------------------------------------- 1 | #ifndef RUBY_COMPAT_H 2 | #define RUBY_COMPAT_H 3 | 4 | /* 5 | * Rules for better ruby C extensions: 6 | * 7 | * Never use the R macros directly, always use R_ 8 | * 9 | * Never compare with RBASIC(obj)->klass, always use 10 | * rb_obj_is_instance_of() 11 | * 12 | * Never use RHASH(obj)->tbl or RHASH_TBL(). 13 | * 14 | */ 15 | 16 | 17 | // Array 18 | #ifndef RARRAY_PTR 19 | #define RARRAY_PTR(obj) RARRAY(obj)->ptr 20 | #endif 21 | 22 | #ifndef RARRAY_LEN 23 | #define RARRAY_LEN(obj) RARRAY(obj)->len 24 | #endif 25 | 26 | // String 27 | #ifndef RSTRING_PTR 28 | #define RSTRING_PTR(obj) RSTRING(obj)->ptr 29 | #endif 30 | 31 | #ifndef RSTRING_LEN 32 | #define RSTRING_LEN(obj) RSTRING(obj)->len 33 | #endif 34 | 35 | #ifndef rb_str_ptr 36 | #define rb_str_ptr(str) RSTRING_PTR(str) 37 | #endif 38 | 39 | #ifndef rb_str_ptr_readonly 40 | #define rb_str_ptr_readonly(str) RSTRING_PTR(str) 41 | #endif 42 | 43 | #ifndef rb_str_flush 44 | #define rb_str_flush(str) 45 | #endif 46 | 47 | #ifndef rb_str_update 48 | #define rb_str_update(str) 49 | #endif 50 | 51 | #ifndef rb_str_len 52 | #define rb_str_len(str) RSTRING_LEN(str) 53 | #endif 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /do_mysql/ext/do_mysql/do_common.c: -------------------------------------------------------------------------------- 1 | ../../../data_objects/lib/data_objects/ext/do_common.c -------------------------------------------------------------------------------- /do_mysql/ext/do_mysql/do_common.h: -------------------------------------------------------------------------------- 1 | ../../../data_objects/lib/data_objects/ext/do_common.h -------------------------------------------------------------------------------- /do_mysql/ext/do_mysql/mysql_compat.h: -------------------------------------------------------------------------------- 1 | #ifdef HAVE_OLD_MYSQL_VERSION 2 | #define MYSQL_TYPE_VAR_STRING FIELD_TYPE_VAR_STRING 3 | #define MYSQL_TYPE_STRING FIELD_TYPE_STRING 4 | #define MYSQL_TYPE_NEWDECIMAL FIELD_TYPE_DECIMAL 5 | #define MYSQL_TYPE_SHORT FIELD_TYPE_SHORT 6 | #define MYSQL_TYPE_LONG FIELD_TYPE_LONG 7 | #define MYSQL_TYPE_FLOAT FIELD_TYPE_FLOAT 8 | #define MYSQL_TYPE_DOUBLE FIELD_TYPE_DOUBLE 9 | #define MYSQL_TYPE_LONGLONG FIELD_TYPE_LONGLONG 10 | #define MYSQL_TYPE_INT24 FIELD_TYPE_INT24 11 | #define MYSQL_TYPE_YEAR FIELD_TYPE_YEAR 12 | #define MYSQL_TYPE_TINY FIELD_TYPE_TINY 13 | #define MYSQL_TYPE_TINY_BLOB FIELD_TYPE_TINY_BLOB 14 | #define MYSQL_TYPE_MEDIUM_BLOB FIELD_TYPE_MEDIUM_BLOB 15 | #define MYSQL_TYPE_LONG_BLOB FIELD_TYPE_LONG_BLOB 16 | #define MYSQL_TYPE_BLOB FIELD_TYPE_BLOB 17 | #define MYSQL_TYPE_DATE FIELD_TYPE_DATE 18 | #define MYSQL_TYPE_NEWDATE FIELD_TYPE_NEWDATE 19 | #define MYSQL_TYPE_DATETIME FIELD_TYPE_DATETIME 20 | #define MYSQL_TYPE_TIME FIELD_TYPE_TIME 21 | #define MYSQL_TYPE_TIMESTAMP FIELD_TYPE_TIMESTAMP 22 | #define MYSQL_TYPE_ENUM FIELD_TYPE_ENUM 23 | #define MYSQL_TYPE_SET FIELD_TYPE_SET 24 | #define MYSQL_TYPE_NULL FIELD_TYPE_NULL 25 | #endif 26 | -------------------------------------------------------------------------------- /do_mysql/lib/do_mysql/encoding.rb: -------------------------------------------------------------------------------- 1 | module DataObjects 2 | module Mysql 3 | module Encoding 4 | MAP = { 5 | "Big5" => "big5", 6 | "CP850" => "cp850", 7 | "KOI8-R" => "koi8r", 8 | "ISO-8859-1" => "latin1", 9 | "ISO-8859-2" => "latin2", 10 | "US-ASCII" => "ascii", 11 | "EUC-JP" => "ujis", 12 | "SJIS" => "sjis", 13 | "ISO-8859-8" => "hebrew", 14 | "TIS-620" => "tis620", 15 | "EUC-KR" => "euckr", 16 | "KOI8-U" => "koi8u", 17 | "GB2312" => "gb2312", 18 | "ISO-8859-7" => "greek", 19 | "Windows-1250" => "cp1250", 20 | "GBK" => "gbk", 21 | "ISO-8859-9" => "latin5", 22 | "UTF-8" => "utf8", 23 | "UTF-8-MB4" => "utf8mb4", 24 | "UTF-16BE" => "ucs2", 25 | "IBM866" => "cp866", 26 | "macCentEuro" => "macce", 27 | "macRoman" => "macroman", 28 | "CP852" => "cp852", 29 | "ISO-8859-13" => "latin7", 30 | "Windows-1251" => "cp1251", 31 | "Windows-1256" => "cp1256", 32 | "Windows-1257" => "cp1257", 33 | "ASCII-8BIT" => "binary", 34 | "Windows-31J" => "cp932", 35 | "eucJP-ms" => "eucjpms" 36 | } 37 | end 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /do_mysql/lib/do_mysql/transaction.rb: -------------------------------------------------------------------------------- 1 | 2 | module DataObjects 3 | 4 | module Mysql 5 | 6 | class Transaction < DataObjects::Transaction 7 | 8 | def begin_prepared 9 | cmd = "XA START '#{id}'" 10 | connection.create_command(cmd).execute_non_query 11 | end 12 | 13 | def commit_prepared 14 | cmd = "XA COMMIT '#{id}'" 15 | connection.create_command(cmd).execute_non_query 16 | end 17 | 18 | def rollback_prepared 19 | cmd = "XA ROLLBACK '#{id}'" 20 | connection.create_command(cmd).execute_non_query 21 | end 22 | 23 | def prepare 24 | finalize_transaction 25 | cmd = "XA PREPARE '#{id}'" 26 | connection.create_command(cmd).execute_non_query 27 | end 28 | 29 | private 30 | 31 | def finalize_transaction 32 | cmd = "XA END '#{id}'" 33 | connection.create_command(cmd).execute_non_query 34 | end 35 | 36 | end 37 | 38 | end 39 | 40 | end 41 | -------------------------------------------------------------------------------- /do_mysql/lib/do_mysql/version.rb: -------------------------------------------------------------------------------- 1 | module DataObjects 2 | module Mysql 3 | VERSION = '0.10.17' 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /do_mysql/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.dataobjects 6 | dataobjects 7 | 0.10.17 8 | ../pom.xml 9 | 10 | do_mysql 11 | jar 12 | do_mysql 13 | A DataObjects.rb driver for MySQL 14 | 15 | 16 | ${pom.parent.groupId} 17 | do_jdbc 18 | ${pom.parent.version} 19 | provided 20 | 21 | 22 | mysql 23 | mysql-connector-java 24 | 5.0.4 25 | 26 | 27 | 28 | 29 | skip_mysql 30 | 31 | true 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /do_mysql/spec/command_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/command_spec' 5 | 6 | describe DataObjects::Mysql::Command do 7 | it_should_behave_like 'a Command' 8 | it_should_behave_like 'a Command with async' 9 | end 10 | -------------------------------------------------------------------------------- /do_mysql/spec/error/sql_error_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/error/sql_error_spec' 5 | 6 | describe 'DataObjects::Mysql raising SQLError' do 7 | it_should_behave_like 'raising a SQLError' 8 | end 9 | -------------------------------------------------------------------------------- /do_mysql/spec/rcov.opts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datamapper/do/16564e6dba587e92e41aba376b46ef765f3bffea/do_mysql/spec/rcov.opts -------------------------------------------------------------------------------- /do_mysql/spec/reader_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/reader_spec' 5 | 6 | describe DataObjects::Mysql::Reader do 7 | it_should_behave_like 'a Reader' 8 | 9 | describe 'reading database metadata' do 10 | 11 | subject { reader } 12 | 13 | let(:connection) { DataObjects::Connection.new(CONFIG.uri) } 14 | let(:command) { connection.create_command(sql) } 15 | let(:reader) { command.execute_reader } 16 | 17 | after do 18 | reader.close 19 | connection.close 20 | end 21 | 22 | describe 'showing correct column field names for a table' do 23 | let(:sql) { 'SHOW COLUMNS FROM `widgets`' } 24 | its(:fields) { should == [ "Field", "Type", "Null", "Key", "Default", "Extra" ] } 25 | end 26 | 27 | describe 'showing correct column field names for variables' do 28 | let(:sql) { "SHOW VARIABLES LIKE 'character_set_connection'" } 29 | its(:fields) { should == [ 'Variable_name', 'Value' ] } 30 | end 31 | 32 | end 33 | 34 | end 35 | -------------------------------------------------------------------------------- /do_mysql/spec/typecast/array_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/array_spec' 5 | 6 | describe 'DataObjects::Mysql with Array' do 7 | it_should_behave_like 'supporting Array' 8 | end 9 | -------------------------------------------------------------------------------- /do_mysql/spec/typecast/bigdecimal_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/bigdecimal_spec' 5 | 6 | describe 'DataObjects::Mysql with BigDecimal' do 7 | it_should_behave_like 'supporting BigDecimal' 8 | it_should_behave_like 'supporting BigDecimal autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_mysql/spec/typecast/boolean_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/boolean_spec' 5 | 6 | describe 'DataObjects::Mysql with Boolean' do 7 | it_should_behave_like 'supporting Boolean' 8 | it_should_behave_like 'supporting Boolean autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_mysql/spec/typecast/byte_array_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/byte_array_spec' 5 | 6 | describe 'DataObjects::Mysql with ByteArray' do 7 | it_should_behave_like 'supporting ByteArray' 8 | end 9 | -------------------------------------------------------------------------------- /do_mysql/spec/typecast/class_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/class_spec' 5 | 6 | describe 'DataObjects::Mysql with Class' do 7 | it_should_behave_like 'supporting Class' 8 | end 9 | -------------------------------------------------------------------------------- /do_mysql/spec/typecast/date_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/date_spec' 5 | 6 | describe 'DataObjects::Mysql with Date' do 7 | it_should_behave_like 'supporting Date' 8 | it_should_behave_like 'supporting Date autocasting' 9 | 10 | describe 'reading 0000-00-00' do 11 | 12 | before do 13 | @connection = DataObjects::Connection.new(CONFIG.uri) 14 | 15 | @connection.create_command("SET SESSION sql_mode = 'ALLOW_INVALID_DATES'").execute_non_query 16 | @connection.create_command("INSERT INTO widgets (release_date) VALUES ('')").execute_non_query 17 | 18 | @command = @connection.create_command("SELECT release_date FROM widgets WHERE release_date = '0000-00-00'") 19 | @reader = @command.execute_reader 20 | @reader.next! 21 | @values = @reader.values 22 | end 23 | 24 | after do 25 | @reader.close 26 | @connection.close 27 | end 28 | 29 | it 'should return the number of created rows' do 30 | @values.first.should be_nil 31 | end 32 | 33 | end 34 | 35 | end 36 | -------------------------------------------------------------------------------- /do_mysql/spec/typecast/datetime_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/datetime_spec' 5 | 6 | describe 'DataObjects::Mysql with DateTime' do 7 | it_should_behave_like 'supporting DateTime' 8 | it_should_behave_like 'supporting DateTime autocasting' 9 | 10 | describe 'reading 0000-00-00 00:00:00' do 11 | 12 | before do 13 | @connection = DataObjects::Connection.new(CONFIG.uri) 14 | 15 | @connection.create_command("SET SESSION sql_mode = 'ALLOW_INVALID_DATES'").execute_non_query 16 | @connection.create_command("INSERT INTO widgets (release_datetime) VALUES ('')").execute_non_query 17 | 18 | @command = @connection.create_command("SELECT release_datetime FROM widgets WHERE release_datetime = '0000-00-00 00:00:00'") 19 | @reader = @command.execute_reader 20 | @reader.next! 21 | @values = @reader.values 22 | end 23 | 24 | after do 25 | @reader.close 26 | @connection.close 27 | end 28 | 29 | it 'should return the number of created rows' do 30 | @values.first.should be_nil 31 | end 32 | 33 | end 34 | 35 | end 36 | -------------------------------------------------------------------------------- /do_mysql/spec/typecast/float_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/float_spec' 5 | 6 | describe 'DataObjects::Mysql with Float' do 7 | it_should_behave_like 'supporting Float' 8 | it_should_behave_like 'supporting Float autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_mysql/spec/typecast/integer_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/integer_spec' 5 | 6 | describe 'DataObjects::Mysql with Integer' do 7 | it_should_behave_like 'supporting Integer' 8 | end 9 | -------------------------------------------------------------------------------- /do_mysql/spec/typecast/nil_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/nil_spec' 5 | 6 | describe 'DataObjects::Mysql with Nil' do 7 | it_should_behave_like 'supporting Nil' 8 | it_should_behave_like 'supporting writing an Nil' 9 | it_should_behave_like 'supporting Nil autocasting' 10 | end 11 | -------------------------------------------------------------------------------- /do_mysql/spec/typecast/other_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/other_spec' 5 | 6 | describe 'DataObjects::H2 with other (unknown) type' do 7 | it_should_behave_like 'supporting other (unknown) type' 8 | end 9 | -------------------------------------------------------------------------------- /do_mysql/spec/typecast/range_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/range_spec' 5 | 6 | describe 'DataObjects::Mysql with Range' do 7 | it_should_behave_like 'supporting Range' 8 | end 9 | -------------------------------------------------------------------------------- /do_mysql/spec/typecast/string_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/string_spec' 5 | 6 | describe 'DataObjects::Mysql with String' do 7 | it_should_behave_like 'supporting String' 8 | end 9 | -------------------------------------------------------------------------------- /do_mysql/spec/typecast/time_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/time_spec' 5 | 6 | describe 'DataObjects::Mysql with Time' do 7 | it_should_behave_like 'supporting Time' 8 | end 9 | -------------------------------------------------------------------------------- /do_mysql/tasks/release.rake: -------------------------------------------------------------------------------- 1 | desc 'Builds all gems (native, binaries for JRuby and Windows)' 2 | task :build_all do 3 | `rake clean` 4 | `rake build` 5 | `rake java gem` 6 | `rake cross native gem RUBY_CC_VERSION=1.8.7:1.9.3:2.0.0:2.1.8:2.2.4:2.3.0` 7 | end 8 | 9 | desc 'Release all gems (native, binaries for JRuby and Windows)' 10 | task :release_all => :build_all do 11 | Dir["pkg/do_mysql-#{DataObjects::Mysql::VERSION}*.gem"].each do |gem_path| 12 | command = "gem push #{gem_path}" 13 | puts "Executing #{command.inspect}:" 14 | sh command 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /do_mysql/tasks/spec.rake: -------------------------------------------------------------------------------- 1 | require 'rspec/core/rake_task' 2 | 3 | RSpec::Core::RakeTask.new(:spec => [:clean, :compile]) do |spec| 4 | spec.pattern = './spec/**/*_spec.rb' 5 | end 6 | 7 | RSpec::Core::RakeTask.new(:rcov => [:clean, :compile]) do |rcov| 8 | rcov.pattern = "./spec/**/*_spec.rb" 9 | rcov.rcov = true 10 | rcov.rcov_opts = File.read('spec/rcov.opts').split(/\s+/) 11 | end 12 | -------------------------------------------------------------------------------- /do_mysql/tasks/ssl.rake: -------------------------------------------------------------------------------- 1 | namespace :ssl do 2 | 3 | task :env do 4 | require ROOT.join('spec', 'spec_helper') 5 | end 6 | 7 | desc "Check test environment for SSL support." 8 | task :check => :env do 9 | ssl_supported, messages = DataObjectsSpecHelpers.test_environment_supports_ssl? 10 | 11 | if DataObjectsSpecHelpers.test_environment_supports_ssl? 12 | puts 13 | puts "** SSL successfully configured for the test environment **" 14 | else 15 | puts 16 | puts "** SSL is not configured for the test environment **" 17 | puts 18 | puts DataObjectsSpecHelpers.test_environment_ssl_config_errors.join("\n") 19 | puts 20 | fail "Run rake ssl:config for instructions on how to configure the test environment." 21 | end 22 | end 23 | 24 | desc "Provide instructions on how to configure SSL in your test environment." 25 | task :config => :env do 26 | puts DataObjectsSpecHelpers.test_environment_ssl_config 27 | end 28 | 29 | end 30 | -------------------------------------------------------------------------------- /do_openedge/.rspec: -------------------------------------------------------------------------------- 1 | --format documentation 2 | --colour 3 | -------------------------------------------------------------------------------- /do_openedge/ChangeLog.markdown: -------------------------------------------------------------------------------- 1 | ## 0.10.17 2016-01-24 2 | 3 | No changes 4 | 5 | ## 0.10.16 2015-05-17 6 | 7 | No changes 8 | 9 | ## 0.10.13 2015-02-15 10 | 11 | No changes 12 | 13 | ## 0.10.14 2014-02-13 14 | 15 | * Don't do DNS lookup in transaction loading 16 | 17 | ## 0.10.13 2013-05-27 18 | 19 | No changes 20 | 21 | ## 0.10.12 2013-01-21 22 | 23 | No changes 24 | 25 | ## 0.10.11 2012-12-29 26 | 27 | No changes 28 | 29 | ## 0.10.10 2012-10-11 30 | 31 | No changes 32 | 33 | ## 0.10.9 2012-08-13 34 | 35 | * First version of do\_openedge 36 | -------------------------------------------------------------------------------- /do_openedge/Gemfile: -------------------------------------------------------------------------------- 1 | source :rubygems 2 | 3 | path '../' 4 | 5 | gemspec 6 | 7 | platforms :jruby do 8 | gem 'jdbc-openedge' 9 | gem 'do_jdbc' 10 | end 11 | 12 | group :development do # Development dependencies (as in the gemspec) 13 | gem 'rake', '~> 0.8.7' 14 | end 15 | -------------------------------------------------------------------------------- /do_openedge/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Abe Voelker, other DataObjects contributors 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /do_openedge/Rakefile: -------------------------------------------------------------------------------- 1 | require 'pathname' 2 | require 'rubygems' 3 | require 'bundler' 4 | require 'rubygems/package_task' 5 | Bundler::GemHelper.install_tasks 6 | 7 | require 'rake' 8 | require 'rake/clean' 9 | 10 | ROOT = Pathname(__FILE__).dirname.expand_path 11 | 12 | require ROOT + 'lib/do_openedge/version' 13 | 14 | JRUBY = RUBY_PLATFORM =~ /java/ 15 | IRONRUBY = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ironruby' 16 | WINDOWS = Gem.win_platform? || (JRUBY && ENV_JAVA['os.name'] =~ /windows/i) 17 | SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS']) 18 | 19 | CLEAN.include(%w[ {tmp,pkg}/ **/*.{o,so,bundle,jar,log,a,gem,dSYM,obj,pdb,exp,DS_Store,rbc,db} ext-java/target ]) 20 | 21 | 22 | Rake::Task['build'].clear_actions if Rake::Task.task_defined?('build') 23 | task :build => [ :java, :gem ] 24 | 25 | FileList['tasks/**/*.rake'].each { |task| import task } 26 | -------------------------------------------------------------------------------- /do_openedge/buildfile: -------------------------------------------------------------------------------- 1 | # Apache Buildr buildfile for do_openedge 2 | # see http://incubator.apache.org/buildr/ for more information on Apache Buildr 3 | require 'buildr' 4 | require 'pathname' 5 | 6 | VERSION_NUMBER = '1.0' 7 | JDBC_SUPPORT = ['data_objects:jdbc:jar:1.0'] 8 | TARGET_DIR = 'pkg/classes' 9 | repositories.remote << 'http://www.ibiblio.org/maven2/' 10 | 11 | define 'do_openedge' do 12 | project.version = VERSION_NUMBER 13 | project.group = 'data_objects.rb' 14 | 15 | manifest['Copyright'] = 'Abe Voelker (C) 2012' 16 | 17 | compile.using :target => '1.5', :lint => 'all', :deprecation => 'true' 18 | 19 | define 'ext-java' do 20 | package(:jar).clean.include(TARGET_DIR) 21 | 22 | jdbc_support_jar = file('../../do_jdbc/lib/do_jdbc_internal.jar') 23 | jdbc_support = artifact('data_objects:jdbc:jar:1.0').from(jdbc_support_jar) 24 | 25 | compile.into(TARGET_DIR).with(JDBC_SUPPORT) 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /do_openedge/ext-java/src/main/java/do_openedge/DoOpenedgeService.java: -------------------------------------------------------------------------------- 1 | package do_openedge; 2 | 3 | import data_objects.drivers.AbstractDataObjectsService; 4 | import data_objects.drivers.DriverDefinition; 5 | 6 | public class DoOpenedgeService extends AbstractDataObjectsService { 7 | 8 | private final static DriverDefinition driver = new OpenEdgeDriverDefinition(); 9 | 10 | /** 11 | * 12 | * @return 13 | */ 14 | @Override 15 | public DriverDefinition getDriverDefinition() { 16 | return driver; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /do_openedge/lib/do_openedge.rb: -------------------------------------------------------------------------------- 1 | require 'data_objects' 2 | 3 | if RUBY_PLATFORM =~ /java/ 4 | require 'do_jdbc' 5 | require 'java' 6 | 7 | module DataObjects 8 | module Openedge 9 | JDBC_DRIVER = 'com.ddtek.jdbc.openedge.OpenEdgeDriver' 10 | end 11 | end 12 | 13 | begin 14 | java.lang.Thread.currentThread.getContextClassLoader().loadClass(DataObjects::Openedge::JDBC_DRIVER, true) 15 | rescue java.lang.ClassNotFoundException 16 | # Load the JDBC driver 17 | require 'jdbc/openedge' # the JDBC driver requires, packaged as a gem 18 | end 19 | 20 | require 'do_openedge/do_openedge' # the Java extension for this DO driver 21 | 22 | # Another way of loading the JDBC Class. This seems to be more reliable 23 | # than Class.forName() within the data_objects.Connection Java class, 24 | # which is currently not working as expected. 25 | java_import DataObjects::Openedge::JDBC_DRIVER 26 | 27 | else 28 | warn "do_openedge is only for use with JRuby" 29 | end 30 | -------------------------------------------------------------------------------- /do_openedge/lib/do_openedge/version.rb: -------------------------------------------------------------------------------- 1 | module DataObjects 2 | module Openedge 3 | VERSION = '0.10.17' 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /do_openedge/spec/command_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/command_spec' 5 | 6 | describe DataObjects::Openedge::Command do 7 | it_should_behave_like 'a Command' 8 | # it_should_behave_like 'a Command with async' 9 | end 10 | -------------------------------------------------------------------------------- /do_openedge/spec/connection_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/connection_spec' 5 | 6 | describe DataObjects::Openedge::Connection do 7 | 8 | before :all do 9 | @driver = CONFIG.scheme 10 | @user = CONFIG.user 11 | @password = CONFIG.pass 12 | @host = CONFIG.host 13 | @port = CONFIG.port 14 | #TODO 15 | #@service = CONFIG.service 16 | @database = CONFIG.database 17 | end 18 | 19 | it_should_behave_like 'a Connection' 20 | #it_should_behave_like 'a Connection with authentication support' 21 | it_should_behave_like 'a Connection with JDBC URL support' 22 | #it_should_behave_like 'a Connection via JDNI' 23 | end 24 | -------------------------------------------------------------------------------- /do_openedge/spec/encoding_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/encoding_spec' 5 | 6 | describe DataObjects::Openedge::Connection do 7 | # it_should_behave_like 'a driver supporting different encodings' 8 | end 9 | -------------------------------------------------------------------------------- /do_openedge/spec/rcov.opts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datamapper/do/16564e6dba587e92e41aba376b46ef765f3bffea/do_openedge/spec/rcov.opts -------------------------------------------------------------------------------- /do_openedge/spec/reader_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/reader_spec' 5 | 6 | describe DataObjects::Openedge::Reader do 7 | it_should_behave_like 'a Reader' 8 | end 9 | -------------------------------------------------------------------------------- /do_openedge/spec/result_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/result_spec' 5 | 6 | # splitting the descibe into two separate declaration avoids 7 | # concurrent execution of the "it_should_behave_like ....." 8 | # needed by some databases (sqlite3) 9 | 10 | describe DataObjects::Openedge::Result do 11 | it_should_behave_like 'a Result' 12 | end 13 | 14 | describe DataObjects::Openedge::Result do 15 | it_should_behave_like 'a Result which returns inserted key with sequences' 16 | end 17 | -------------------------------------------------------------------------------- /do_openedge/spec/typecast/array_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/array_spec' 5 | 6 | describe 'DataObjects::Openedge with Array' do 7 | it_should_behave_like 'supporting Array' 8 | end 9 | -------------------------------------------------------------------------------- /do_openedge/spec/typecast/boolean_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/boolean_spec' 5 | 6 | describe 'DataObjects::Openedge with Boolean' do 7 | it_should_behave_like 'supporting Boolean' 8 | it_should_behave_like 'supporting Boolean autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_openedge/spec/typecast/date_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/date_spec' 5 | 6 | describe 'DataObjects::Openedge with Date' do 7 | it_should_behave_like 'supporting Date' 8 | it_should_behave_like 'supporting Date autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_openedge/spec/typecast/datetime_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/datetime_spec' 5 | 6 | describe 'DataObjects::Openedge with DateTime' do 7 | it_should_behave_like 'supporting DateTime' 8 | it_should_behave_like 'supporting DateTime autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_openedge/spec/typecast/float_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/float_spec' 5 | 6 | describe 'DataObjects::Openedge with Float' do 7 | it_should_behave_like 'supporting Float' 8 | it_should_behave_like 'supporting Float autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_openedge/spec/typecast/integer_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/integer_spec' 5 | 6 | describe 'DataObjects::Openedge with Integer' do 7 | it_should_behave_like 'supporting Integer' 8 | end 9 | -------------------------------------------------------------------------------- /do_openedge/spec/typecast/nil_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/nil_spec' 5 | 6 | describe 'DataObjects::Openedge with Nil' do 7 | it_should_behave_like 'supporting Nil' 8 | it_should_behave_like 'supporting writing an Nil' 9 | it_should_behave_like 'supporting Nil autocasting' 10 | end 11 | -------------------------------------------------------------------------------- /do_openedge/spec/typecast/other_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/other_spec' 5 | 6 | describe 'DataObjects::Openedge with other (unknown) type' do 7 | it_should_behave_like 'supporting other (unknown) type' 8 | end 9 | -------------------------------------------------------------------------------- /do_openedge/spec/typecast/range_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/range_spec' 5 | 6 | describe 'DataObjects::Openedge with Range' do 7 | it_should_behave_like 'supporting Range' 8 | end 9 | -------------------------------------------------------------------------------- /do_openedge/spec/typecast/string_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/string_spec' 5 | 6 | describe 'DataObjects::Openedge with String' do 7 | it_should_behave_like 'supporting String' 8 | end 9 | -------------------------------------------------------------------------------- /do_openedge/spec/typecast/time_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/time_spec' 5 | 6 | describe 'DataObjects::Openedge with Time' do 7 | it_should_behave_like 'supporting Time' 8 | end 9 | -------------------------------------------------------------------------------- /do_openedge/tasks/compile.rake: -------------------------------------------------------------------------------- 1 | begin 2 | gem 'rake-compiler', '~>0.7' 3 | require 'rake/javaextensiontask' 4 | 5 | def gemspec 6 | @clean_gemspec ||= Gem::Specification::load(File.expand_path('../../do_openedge.gemspec', __FILE__)) 7 | end 8 | 9 | Rake::JavaExtensionTask.new('do_openedge', gemspec) do |ext| 10 | ext.ext_dir = 'ext-java/src/main/java' 11 | ext.lib_dir = "lib/#{gemspec.name}" 12 | ext.debug = ENV.has_key?('DO_JAVA_DEBUG') && ENV['DO_JAVA_DEBUG'] 13 | ext.classpath = '../do_jdbc/lib/do_jdbc_internal.jar' 14 | ext.java_compiling do |gem| 15 | gem.add_dependency 'jdbc-openedge' 16 | gem.add_dependency 'do_jdbc', '0.10.17' 17 | end 18 | end 19 | 20 | # do_openedge is only available for JRuby: the normal behaviour of rake-compiler 21 | # is to only chain 'compile:PLATFORM' tasks to 'compile' where PLATFORM is the 22 | # platform of the current interpreter (i.e. 'compile:java' to 'compile' only 23 | # if running on JRuby). However, we always want to compile for Java, even if 24 | # running from MRI. 25 | task 'compile:do_openedge' => ['compile:do_openedge:java'] 26 | task 'compile' => ['compile:java'] 27 | 28 | rescue LoadError 29 | warn "To compile, install rake-compiler (gem install rake-compiler)" 30 | end 31 | -------------------------------------------------------------------------------- /do_openedge/tasks/release.rake: -------------------------------------------------------------------------------- 1 | desc 'Builds all gems (native, binaries for JRuby and Windows)' 2 | task :build_all do 3 | `rake clean` 4 | `rake java gem` 5 | end 6 | 7 | desc 'Release all gems (native, binaries for JRuby and Windows)' 8 | task :release_all => :build_all do 9 | Dir["pkg/do_openedge-#{DataObjects::Openedge::VERSION}*.gem"].each do |gem_path| 10 | command = "gem push #{gem_path}" 11 | puts "Executing #{command.inspect}:" 12 | sh command 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /do_openedge/tasks/spec.rake: -------------------------------------------------------------------------------- 1 | require 'rspec/core/rake_task' 2 | 3 | RSpec::Core::RakeTask.new(:spec => [:clean, :compile]) do |spec| 4 | spec.pattern = './spec/**/*_spec.rb' 5 | end 6 | 7 | RSpec::Core::RakeTask.new(:rcov => [:clean, :compile]) do |rcov| 8 | rcov.pattern = "./spec/**/*_spec.rb" 9 | rcov.rcov = true 10 | rcov.rcov_opts = File.read('spec/rcov.opts').split(/\s+/) 11 | end 12 | -------------------------------------------------------------------------------- /do_oracle/.gitignore: -------------------------------------------------------------------------------- 1 | *.old -------------------------------------------------------------------------------- /do_oracle/.rspec: -------------------------------------------------------------------------------- 1 | --format documentation 2 | --colour 3 | -------------------------------------------------------------------------------- /do_oracle/ChangeLog.markdown: -------------------------------------------------------------------------------- 1 | ## 0.10.17 2016-01-24 2 | 3 | No changes 4 | 5 | ## 0.10.16 2015-05-17 6 | 7 | No changes 8 | 9 | ## 0.10.15 2015-02-15 10 | 11 | * Ruby 2.2 support 12 | * Windows support on 2.1.x and 2.2.x 13 | 14 | ## 0.10.14 2014-02-13 15 | 16 | * Don't do DNS lookup in transaction loading 17 | 18 | ## 0.10.13 2013-05-27 19 | 20 | * Fix compilation on Ruby 2.0 21 | * Windows binary for Ruby 2.0 22 | 23 | ## 0.10.12 2013-01-21 24 | 25 | No changes 26 | 27 | ## 0.10.11 2012-12-29 28 | 29 | * Rename C symbols to prevent name collitions 30 | 31 | ## 0.10.10 2012-10-11 32 | 33 | No changes 34 | 35 | ## 0.10.9 2012-08-13 36 | 37 | * Fix segfault when converting Time into DateTime 38 | 39 | ## 0.10.8 2012-02-10 40 | 41 | * Ruby 1.9.3 compatibility 42 | 43 | ## 0.10.7 2011-10-13 44 | 45 | No changes 46 | 47 | ## 0.10.6 2011-05-22 48 | 49 | No changes 50 | 51 | ## 0.10.5 2011-05-03 52 | 53 | No changes 54 | 55 | ## 0.10.4 2011-04-28 56 | 57 | New features 58 | * Add save point to transactions (all) 59 | * JRuby 1.9 mode support (encodings etc.) 60 | 61 | Bugfixes 62 | * Fix bug when using nested transactions in concurrent scenarios (all) 63 | * Use column aliases instead of names (jruby) 64 | 65 | Other 66 | * Switch back to RSpec 67 | 68 | ## 0.10.3 2011-01-30 69 | * No changes 70 | 71 | ## 0.10.2 2010-05-19 72 | * Rework logging for making callbacks possible 73 | 74 | ## 0.10.1 2010-01-08 75 | 76 | Initial release. 77 | -------------------------------------------------------------------------------- /do_oracle/Gemfile: -------------------------------------------------------------------------------- 1 | source :rubygems 2 | 3 | path '../' 4 | 5 | gemspec 6 | 7 | platforms :jruby do 8 | gem 'do_jdbc' 9 | end 10 | 11 | group :development do # Development dependencies (as in the gemspec) 12 | gem 'rake' 13 | end 14 | -------------------------------------------------------------------------------- /do_oracle/INSTALL.markdown: -------------------------------------------------------------------------------- 1 | INSTALLATION 2 | ============ 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /do_oracle/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2007 - 2011 Yehuda Katz, Dirkjan Bussink, Raimonds Simanovskis 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /do_oracle/Rakefile: -------------------------------------------------------------------------------- 1 | require 'pathname' 2 | require 'rubygems' 3 | require 'bundler' 4 | require 'rubygems/package_task' 5 | Bundler::GemHelper.install_tasks 6 | 7 | require 'rake' 8 | require 'rake/clean' 9 | 10 | ROOT = Pathname(__FILE__).dirname.expand_path 11 | 12 | require ROOT + 'lib/do_oracle/version' 13 | 14 | JRUBY = RUBY_PLATFORM =~ /java/ 15 | IRONRUBY = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ironruby' 16 | WINDOWS = Gem.win_platform? || (JRUBY && ENV_JAVA['os.name'] =~ /windows/i) 17 | SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS']) 18 | BINARY_VERSION = '10.2.0.4.0' 19 | 20 | CLEAN.include(%w[ {tmp,pkg}/ **/*.{o,so,bundle,jar,log,a,gem,dSYM,obj,pdb,exp,DS_Store,rbc,db} ext/do_oracle/Makefile ext-java/target ]) 21 | 22 | 23 | if JRUBY 24 | Rake::Task['build'].clear_actions if Rake::Task.task_defined?('build') 25 | Rake::Task['install'].clear_actions if Rake::Task.task_defined?('install') 26 | task :build => [ :java, :gem ] 27 | task :install do 28 | sh "#{Config::CONFIG['RUBY_INSTALL_NAME']} -S gem install pkg/do_oracle-#{DataObjects::Oracle::VERSION}-java.gem" 29 | end 30 | end 31 | 32 | FileList['tasks/**/*.rake'].each { |task| import task } 33 | -------------------------------------------------------------------------------- /do_oracle/buildfile: -------------------------------------------------------------------------------- 1 | # Apache Buildr buildfile for do_oracle 2 | # see http://incubator.apache.org/buildr/ for more information on Apache Buildr 3 | require 'buildr' 4 | require 'pathname' 5 | 6 | VERSION_NUMBER = '1.0' 7 | JDBC_SUPPORT = ['data_objects:jdbc:jar:1.0'] 8 | TARGET_DIR = 'pkg/classes' 9 | repositories.remote << 'http://www.ibiblio.org/maven2/' 10 | 11 | define 'do_oracle' do 12 | project.version = VERSION_NUMBER 13 | project.group = 'data_objects.rb' 14 | 15 | manifest['Copyright'] = 'Raimonds Simanovskis (C) 2009' 16 | 17 | compile.using :target => '1.5', :lint => 'all', :deprecation => 'true' 18 | 19 | define 'ext-java' do 20 | package(:jar).clean.include(TARGET_DIR) 21 | 22 | jdbc_support_jar = file('../../do_jdbc/lib/do_jdbc_internal.jar') 23 | jdbc_support = artifact('data_objects:jdbc:jar:1.0').from(jdbc_support_jar) 24 | 25 | compile.into(TARGET_DIR).with(JDBC_SUPPORT) 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /do_oracle/ext-java/src/main/java/do_oracle/DoOracleService.java: -------------------------------------------------------------------------------- 1 | package do_oracle; 2 | 3 | import data_objects.drivers.AbstractDataObjectsService; 4 | import data_objects.drivers.DriverDefinition; 5 | 6 | public class DoOracleService extends AbstractDataObjectsService { 7 | 8 | private final static DriverDefinition driver = new OracleDriverDefinition(); 9 | 10 | /** 11 | * 12 | * @return 13 | */ 14 | @Override 15 | public DriverDefinition getDriverDefinition() { 16 | return driver; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /do_oracle/ext/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | mkmf.log 3 | -------------------------------------------------------------------------------- /do_oracle/ext/do_oracle/extconf.rb: -------------------------------------------------------------------------------- 1 | ENV["RC_ARCHS"] = "" if RUBY_PLATFORM =~ /darwin/ 2 | 3 | # Loads mkmf which is used to make makefiles for Ruby extensions 4 | require 'mkmf' 5 | require 'date' 6 | 7 | # need to check dynamically for libraries and include files directories 8 | def config_value(type) 9 | case type 10 | when 'libdir' 11 | '/usr/local/oracle/instantclient_10_2' 12 | when 'includedir' 13 | '/usr/local/oracle/instantclient_10_2/sdk/include' 14 | end 15 | end 16 | 17 | def have_build_env 18 | # have_library('occi') && 19 | # have_library('clntsh') && 20 | # have_header('oci.h') 21 | true 22 | end 23 | 24 | # dir_config('oracle-client', config_value('includedir'), config_value('libdir')) 25 | 26 | if have_build_env 27 | 28 | $CFLAGS << ' -Wall ' unless RUBY_PLATFORM =~ /mswin/ 29 | if RUBY_VERSION < '1.8.6' 30 | $CFLAGS << ' -DRUBY_LESS_THAN_186' 31 | end 32 | 33 | unless DateTime.respond_to?(:new!) 34 | $CFLAGS << ' -DHAVE_NO_DATETIME_NEWBANG' 35 | end 36 | 37 | create_makefile("do_oracle/do_oracle") 38 | else 39 | puts 'Could not find Oracle build environment (libraries & headers): Makefile not created' 40 | exit(1) 41 | end 42 | -------------------------------------------------------------------------------- /do_oracle/lib/do_oracle/transaction.rb: -------------------------------------------------------------------------------- 1 | module DataObjects 2 | 3 | module Oracle 4 | 5 | class Transaction < DataObjects::Transaction 6 | 7 | def begin 8 | connection.instance_variable_get("@connection").autocommit = false 9 | end 10 | 11 | def commit 12 | connection.instance_variable_get("@connection").commit 13 | ensure 14 | connection.instance_variable_get("@connection").autocommit = true 15 | end 16 | 17 | def rollback 18 | connection.instance_variable_get("@connection").rollback 19 | ensure 20 | connection.instance_variable_get("@connection").autocommit = true 21 | end 22 | 23 | def rollback_prepared 24 | # TODO: what should be done differently? 25 | rollback 26 | end 27 | 28 | def prepare 29 | # TODO: what should be done here? 30 | end 31 | 32 | end 33 | 34 | end 35 | 36 | end 37 | -------------------------------------------------------------------------------- /do_oracle/lib/do_oracle/version.rb: -------------------------------------------------------------------------------- 1 | module DataObjects 2 | module Oracle 3 | VERSION = '0.10.17' 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /do_oracle/spec/connection_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/connection_spec' 5 | 6 | describe DataObjects::Oracle::Connection do 7 | 8 | before :all do 9 | @driver = CONFIG.scheme 10 | @user = CONFIG.user 11 | @password = CONFIG.pass 12 | @host = CONFIG.host 13 | @port = CONFIG.port 14 | @database = CONFIG.database 15 | end 16 | 17 | it_should_behave_like 'a Connection' 18 | it_should_behave_like 'a Connection with authentication support' 19 | it_should_behave_like 'a Connection with JDBC URL support' if JRUBY 20 | it_should_behave_like 'a Connection via JDNI' if JRUBY 21 | end 22 | -------------------------------------------------------------------------------- /do_oracle/spec/encoding_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | # require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | # require 'data_objects/spec/shared/encoding_spec' 5 | # 6 | # describe DataObjects::Oracle::Connection do 7 | # it_should_behave_like 'a driver supporting different encodings' 8 | # end 9 | 10 | 11 | # Oracle does not support dynamic changing of client character set 12 | # Client character set is set using NLS_LANG environment variable (e.g. equal to AMERICAN_AMERICA.UTF8) 13 | -------------------------------------------------------------------------------- /do_oracle/spec/rcov.opts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datamapper/do/16564e6dba587e92e41aba376b46ef765f3bffea/do_oracle/spec/rcov.opts -------------------------------------------------------------------------------- /do_oracle/spec/reader_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/reader_spec' 5 | 6 | describe DataObjects::Oracle::Reader do 7 | it_should_behave_like 'a Reader' 8 | end 9 | -------------------------------------------------------------------------------- /do_oracle/spec/typecast/array_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/array_spec' 5 | 6 | describe 'DataObjects::Oracle with Array' do 7 | it_should_behave_like 'supporting Array' 8 | end 9 | -------------------------------------------------------------------------------- /do_oracle/spec/typecast/bigdecimal_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/bigdecimal_spec' 5 | 6 | describe 'DataObjects::Oracle with BigDecimal' do 7 | it_should_behave_like 'supporting BigDecimal' 8 | it_should_behave_like 'supporting BigDecimal autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_oracle/spec/typecast/boolean_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/boolean_spec' 5 | 6 | describe 'DataObjects::Oracle with Boolean' do 7 | it_should_behave_like 'supporting Boolean' 8 | it_should_behave_like 'supporting Boolean autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_oracle/spec/typecast/date_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/date_spec' 5 | 6 | describe 'DataObjects::Oracle with Date' do 7 | it_should_behave_like 'supporting Date' 8 | 9 | # Oracle will cast DATE type to Time 10 | # it_should_behave_like 'supporting Date autocasting' 11 | end 12 | -------------------------------------------------------------------------------- /do_oracle/spec/typecast/datetime_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/datetime_spec' 5 | 6 | describe 'DataObjects::Oracle with DateTime' do 7 | it_should_behave_like 'supporting DateTime' 8 | # it_should_behave_like 'supporting DateTime autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_oracle/spec/typecast/integer_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/integer_spec' 5 | 6 | describe 'DataObjects::Oracle with Integer' do 7 | it_should_behave_like 'supporting Integer' 8 | end 9 | -------------------------------------------------------------------------------- /do_oracle/spec/typecast/nil_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/nil_spec' 5 | 6 | describe 'DataObjects::Oracle with Nil' do 7 | it_should_behave_like 'supporting Nil' 8 | it_should_behave_like 'supporting writing an Nil' 9 | it_should_behave_like 'supporting Nil autocasting' 10 | end 11 | -------------------------------------------------------------------------------- /do_oracle/spec/typecast/other_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/other_spec' 5 | 6 | describe 'DataObjects::H2 with other (unknown) type' do 7 | it_should_behave_like 'supporting other (unknown) type' 8 | end 9 | -------------------------------------------------------------------------------- /do_oracle/spec/typecast/range_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/range_spec' 5 | 6 | describe 'DataObjects::Oracle with Range' do 7 | it_should_behave_like 'supporting Range' 8 | end 9 | -------------------------------------------------------------------------------- /do_oracle/tasks/release.rake: -------------------------------------------------------------------------------- 1 | desc 'Builds all gems (native, binaries for JRuby and Windows)' 2 | task :build_all do 3 | `rake clean` 4 | `rake build` 5 | `rake java gem` 6 | `rake cross native gem RUBY_CC_VERSION=1.8.7:1.9.3:2.0.0:2.1.8:2.2.4:2.3.0` 7 | end 8 | 9 | desc 'Release all gems (native, binaries for JRuby and Windows)' 10 | task :release_all => :build_all do 11 | Dir["pkg/do_oracle-#{DataObjects::Oracle::VERSION}*.gem"].each do |gem_path| 12 | command = "gem push #{gem_path}" 13 | puts "Executing #{command.inspect}:" 14 | sh command 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /do_oracle/tasks/spec.rake: -------------------------------------------------------------------------------- 1 | require 'rspec/core/rake_task' 2 | 3 | RSpec::Core::RakeTask.new(:spec => [:clean, :compile]) do |spec| 4 | spec.pattern = './spec/**/*_spec.rb' 5 | end 6 | 7 | RSpec::Core::RakeTask.new(:rcov => [:clean, :compile]) do |rcov| 8 | rcov.pattern = "./spec/**/*_spec.rb" 9 | rcov.rcov = true 10 | rcov.rcov_opts = File.read('spec/rcov.opts').split(/\s+/) 11 | end 12 | -------------------------------------------------------------------------------- /do_postgres/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datamapper/do/16564e6dba587e92e41aba376b46ef765f3bffea/do_postgres/.gitignore -------------------------------------------------------------------------------- /do_postgres/.rspec: -------------------------------------------------------------------------------- 1 | --format documentation 2 | --colour 3 | -------------------------------------------------------------------------------- /do_postgres/Gemfile: -------------------------------------------------------------------------------- 1 | source :rubygems 2 | 3 | path '../' 4 | 5 | gemspec 6 | 7 | platforms :jruby do 8 | gem 'jdbc-postgres', '>=8.2' 9 | gem 'do_jdbc', '0.10.17' 10 | end 11 | 12 | group :development do # Development dependencies (as in the gemspec) 13 | gem 'rake' 14 | end 15 | -------------------------------------------------------------------------------- /do_postgres/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2007 - 2011 Yehuda Katz, Dirkjan Bussink 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /do_postgres/Rakefile: -------------------------------------------------------------------------------- 1 | require 'pathname' 2 | require 'rubygems' 3 | require 'bundler' 4 | require 'rubygems/package_task' 5 | Bundler::GemHelper.install_tasks 6 | 7 | require 'rake' 8 | require 'rake/clean' 9 | 10 | ROOT = Pathname(__FILE__).dirname.expand_path 11 | 12 | require ROOT + 'lib/do_postgres/version' 13 | 14 | JRUBY = RUBY_PLATFORM =~ /java/ 15 | IRONRUBY = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ironruby' 16 | WINDOWS = Gem.win_platform? || (JRUBY && ENV_JAVA['os.name'] =~ /windows/i) 17 | SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS']) 18 | BINARY_VERSION = '8.4.12' 19 | 20 | CLEAN.include(%w[ {tmp,pkg}/ **/*.{o,so,bundle,jar,log,a,gem,dSYM,obj,pdb,exp,DS_Store,rbc,db} ext/do_postgres/Makefile ext-java/target ]) 21 | 22 | 23 | if JRUBY 24 | Rake::Task['build'].clear_actions if Rake::Task.task_defined?('build') 25 | Rake::Task['install'].clear_actions if Rake::Task.task_defined?('install') 26 | task :build => [ :java, :gem ] 27 | task :install do 28 | sh "#{Config::CONFIG['RUBY_INSTALL_NAME']} -S gem install pkg/do_postgres-#{DataObjects::Postgres::VERSION}-java.gem" 29 | end 30 | end 31 | 32 | FileList['tasks/**/*.rake'].each { |task| import task } 33 | -------------------------------------------------------------------------------- /do_postgres/buildfile: -------------------------------------------------------------------------------- 1 | # Apache Buildr buildfile for do_postgres 2 | # see http://incubator.apache.org/buildr/ for more information on Apache Buildr 3 | require 'buildr' 4 | require 'pathname' 5 | 6 | VERSION_NUMBER = '1.0' 7 | JDBC_SUPPORT = ['data_objects:jdbc:jar:1.0'] 8 | TARGET_DIR = 'pkg/classes' 9 | repositories.remote << 'http://www.ibiblio.org/maven2/' 10 | 11 | define 'do_postgres' do 12 | project.version = VERSION_NUMBER 13 | project.group = 'data_objects.rb' 14 | 15 | manifest['Copyright'] = 'Alex Coles (C) 2008-2011' 16 | 17 | compile.using :target => '1.5', :lint => 'all', :deprecation => 'true' 18 | 19 | define 'ext-java' do 20 | package(:jar).clean.include(TARGET_DIR) 21 | 22 | jdbc_support_jar = file('../../do_jdbc/lib/do_jdbc_internal.jar') 23 | jdbc_support = artifact('data_objects:jdbc:jar:1.0').from(jdbc_support_jar) 24 | 25 | compile.into(TARGET_DIR).with(JDBC_SUPPORT) 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /do_postgres/ext-java/src/main/java/do_postgres/DoPostgresService.java: -------------------------------------------------------------------------------- 1 | package do_postgres; 2 | 3 | import data_objects.drivers.AbstractDataObjectsService; 4 | import data_objects.drivers.DriverDefinition; 5 | 6 | public class DoPostgresService extends AbstractDataObjectsService { 7 | 8 | private final static DriverDefinition driver = new PostgresDriverDefinition(); 9 | 10 | /** 11 | * 12 | * @return 13 | */ 14 | @Override 15 | public DriverDefinition getDriverDefinition() { 16 | return driver; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /do_postgres/ext/do_postgres/compat.h: -------------------------------------------------------------------------------- 1 | #ifndef RUBY_COMPAT_H 2 | #define RUBY_COMPAT_H 3 | 4 | /* 5 | * Rules for better ruby C extensions: 6 | * 7 | * Never use the R macros directly, always use R_ 8 | * 9 | * Never compare with RBASIC(obj)->klass, always use 10 | * rb_obj_is_instance_of() 11 | * 12 | * Never use RHASH(obj)->tbl or RHASH_TBL(). 13 | * 14 | */ 15 | 16 | 17 | // Array 18 | #ifndef RARRAY_PTR 19 | #define RARRAY_PTR(obj) RARRAY(obj)->ptr 20 | #endif 21 | 22 | #ifndef RARRAY_LEN 23 | #define RARRAY_LEN(obj) RARRAY(obj)->len 24 | #endif 25 | 26 | // String 27 | #ifndef RSTRING_PTR 28 | #define RSTRING_PTR(obj) RSTRING(obj)->ptr 29 | #endif 30 | 31 | #ifndef RSTRING_LEN 32 | #define RSTRING_LEN(obj) RSTRING(obj)->len 33 | #endif 34 | 35 | #ifndef rb_str_ptr 36 | #define rb_str_ptr(str) RSTRING_PTR(str) 37 | #endif 38 | 39 | #ifndef rb_str_ptr_readonly 40 | #define rb_str_ptr_readonly(str) RSTRING_PTR(str) 41 | #endif 42 | 43 | #ifndef rb_str_flush 44 | #define rb_str_flush(str) 45 | #endif 46 | 47 | #ifndef rb_str_update 48 | #define rb_str_update(str) 49 | #endif 50 | 51 | #ifndef rb_str_len 52 | #define rb_str_len(str) RSTRING_LEN(str) 53 | #endif 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /do_postgres/ext/do_postgres/do_common.c: -------------------------------------------------------------------------------- 1 | ../../../data_objects/lib/data_objects/ext/do_common.c -------------------------------------------------------------------------------- /do_postgres/ext/do_postgres/do_common.h: -------------------------------------------------------------------------------- 1 | ../../../data_objects/lib/data_objects/ext/do_common.h -------------------------------------------------------------------------------- /do_postgres/lib/do_postgres.rb: -------------------------------------------------------------------------------- 1 | require 'data_objects' 2 | if RUBY_PLATFORM =~ /java/ 3 | require 'do_jdbc' 4 | require 'java' 5 | 6 | module DataObjects 7 | module Postgres 8 | JDBC_DRIVER = 'org.postgresql.Driver' 9 | end 10 | end 11 | 12 | begin 13 | java.lang.Thread.currentThread.getContextClassLoader().loadClass(DataObjects::Postgres::JDBC_DRIVER, true) 14 | rescue java.lang.ClassNotFoundException 15 | require 'jdbc/postgres' # the JDBC driver, packaged as a gem 16 | Jdbc::Postgres.load_driver if Jdbc::Postgres.respond_to?(:load_driver) 17 | end 18 | 19 | # Another way of loading the JDBC Class. This seems to be more reliable 20 | # than Class.forName() within the data_objects.Connection Java class, 21 | # which is currently not working as expected. 22 | java_import DataObjects::Postgres::JDBC_DRIVER 23 | 24 | end 25 | 26 | begin 27 | require 'do_postgres/do_postgres' 28 | rescue LoadError 29 | if RUBY_PLATFORM =~ /mingw|mswin/ then 30 | RUBY_VERSION =~ /(\d+.\d+)/ 31 | require "do_postgres/#{$1}/do_postgres" 32 | else 33 | raise 34 | end 35 | end 36 | 37 | require 'do_postgres/version' 38 | require 'do_postgres/transaction' if RUBY_PLATFORM !~ /java/ 39 | require 'do_postgres/encoding' 40 | -------------------------------------------------------------------------------- /do_postgres/lib/do_postgres/transaction.rb: -------------------------------------------------------------------------------- 1 | 2 | module DataObjects 3 | 4 | module Postgres 5 | 6 | class Transaction < DataObjects::Transaction 7 | 8 | def begin 9 | cmd = "BEGIN" 10 | connection.create_command(cmd).execute_non_query 11 | end 12 | 13 | def begin_prepared 14 | cmd = "BEGIN" 15 | connection.create_command(cmd).execute_non_query 16 | end 17 | 18 | def commit 19 | cmd = "COMMIT" 20 | connection.create_command(cmd).execute_non_query 21 | end 22 | 23 | def commit_prepared 24 | cmd = "COMMIT PREPARED '#{id}'" 25 | connection.create_command(cmd).execute_non_query 26 | end 27 | 28 | def rollback 29 | cmd = "ROLLBACK" 30 | connection.create_command(cmd).execute_non_query 31 | end 32 | 33 | def rollback_prepared 34 | cmd = "ROLLBACK PREPARED '#{id}'" 35 | connection.create_command(cmd).execute_non_query 36 | end 37 | 38 | def prepare 39 | cmd = "PREPARE TRANSACTION '#{id}'" 40 | connection.create_command(cmd).execute_non_query 41 | end 42 | 43 | end 44 | 45 | end 46 | 47 | end 48 | -------------------------------------------------------------------------------- /do_postgres/lib/do_postgres/version.rb: -------------------------------------------------------------------------------- 1 | module DataObjects 2 | module Postgres 3 | VERSION = '0.10.17' 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /do_postgres/script/timezone_spec_runner.rb: -------------------------------------------------------------------------------- 1 | path = File.dirname(__FILE__) 2 | zones = IO.readlines("#{path}/timezones.txt") 3 | 4 | total = 0 5 | pass = 0 6 | 7 | zones.each do |zone| 8 | zone.chomp! 9 | 10 | result = %x[export TZ="#{zone}" && spec #{path}/../spec/timezone_spec.rb 2> /dev/null] 11 | 12 | total += 1 13 | 14 | 15 | printf("%60s | ", zone) 16 | 17 | if result.match(/FAILED/) 18 | puts "FAIL" 19 | else 20 | puts "pass" 21 | pass += 1 22 | end 23 | 24 | end 25 | 26 | puts "="*80 27 | puts "="*80 28 | puts "#{pass}/#{total} = %d" % (pass.to_f/total).round 29 | -------------------------------------------------------------------------------- /do_postgres/spec/encoding_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/encoding_spec' 5 | 6 | describe DataObjects::Postgres::Connection do 7 | unless JRUBY 8 | # Do NOT test this on JRuby: 9 | # 10 | # http://jdbc.postgresql.org/documentation/80/connect.html 11 | # 12 | # According to the Postgres documentation, as of Postgres 7.2, multibyte 13 | # support is enabled by default in the server. The underlying JDBC Driver 14 | # handles setting the internal client_encoding setting appropriately. It 15 | # can be overridden -- but for now, we won't support doing this. 16 | # 17 | it_should_behave_like 'a driver supporting different encodings' 18 | it_should_behave_like 'returning correctly encoded strings for the default database encoding' 19 | it_should_behave_like 'returning correctly encoded strings for the default internal encoding' 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /do_postgres/spec/error/sql_error_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/error/sql_error_spec' 5 | 6 | describe 'DataObjects::Postgres raising SQLError' do 7 | it_should_behave_like 'raising a SQLError' 8 | end 9 | -------------------------------------------------------------------------------- /do_postgres/spec/rcov.opts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datamapper/do/16564e6dba587e92e41aba376b46ef765f3bffea/do_postgres/spec/rcov.opts -------------------------------------------------------------------------------- /do_postgres/spec/reader_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/reader_spec' 5 | 6 | describe DataObjects::Postgres::Reader do 7 | it_should_behave_like 'a Reader' 8 | end 9 | -------------------------------------------------------------------------------- /do_postgres/spec/typecast/array_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/array_spec' 5 | 6 | describe 'DataObjects::Postgres with Array' do 7 | it_should_behave_like 'supporting Array' 8 | end 9 | -------------------------------------------------------------------------------- /do_postgres/spec/typecast/bigdecimal_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/bigdecimal_spec' 5 | 6 | describe 'DataObjects::Postgres with BigDecimal' do 7 | it_should_behave_like 'supporting BigDecimal' 8 | it_should_behave_like 'supporting BigDecimal autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_postgres/spec/typecast/boolean_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/boolean_spec' 5 | 6 | describe 'DataObjects::Postgres with Boolean' do 7 | it_should_behave_like 'supporting Boolean' 8 | it_should_behave_like 'supporting Boolean autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_postgres/spec/typecast/byte_array_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/byte_array_spec' 5 | 6 | describe 'DataObjects::Postgres with ByteArray' do 7 | it_should_behave_like 'supporting ByteArray' 8 | end 9 | -------------------------------------------------------------------------------- /do_postgres/spec/typecast/class_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/class_spec' 5 | 6 | describe 'DataObjects::Postgres with Class' do 7 | it_should_behave_like 'supporting Class' 8 | end 9 | -------------------------------------------------------------------------------- /do_postgres/spec/typecast/date_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/date_spec' 5 | 6 | describe 'DataObjects::Postgres with Date' do 7 | it_should_behave_like 'supporting Date' 8 | it_should_behave_like 'supporting Date autocasting' 9 | 10 | describe 'exotic dates' do 11 | 12 | before do 13 | @connection = DataObjects::Connection.new(CONFIG.uri) 14 | @connection.create_command("INSERT INTO widgets (release_date) VALUES ('0001-01-01')").execute_non_query 15 | 16 | @command = @connection.create_command("SELECT release_date FROM widgets WHERE release_date = '0001-01-01'") 17 | @reader = @command.execute_reader 18 | @reader.next! 19 | @values = @reader.values 20 | end 21 | 22 | after do 23 | @reader.close 24 | @connection.close 25 | end 26 | 27 | it 'should return the number of created rows' do 28 | @values.first.should == Date.civil(1, 1, 1) 29 | end 30 | 31 | end 32 | 33 | end 34 | -------------------------------------------------------------------------------- /do_postgres/spec/typecast/datetime_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/datetime_spec' 5 | 6 | describe 'DataObjects::Postgres with DateTime' do 7 | it_should_behave_like 'supporting DateTime' 8 | it_should_behave_like 'supporting DateTime autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_postgres/spec/typecast/float_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/float_spec' 5 | 6 | describe 'DataObjects::Postgres with Float' do 7 | it_should_behave_like 'supporting Float' 8 | it_should_behave_like 'supporting Float autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_postgres/spec/typecast/integer_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/integer_spec' 5 | 6 | describe 'DataObjects::Postgres with Integer' do 7 | it_should_behave_like 'supporting Integer' 8 | end 9 | -------------------------------------------------------------------------------- /do_postgres/spec/typecast/nil_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/nil_spec' 5 | 6 | describe 'DataObjects::Postgres with Nil' do 7 | it_should_behave_like 'supporting Nil' 8 | # it_should_behave_like 'supporting writing an Nil' 9 | it_should_behave_like 'supporting Nil autocasting' 10 | end 11 | -------------------------------------------------------------------------------- /do_postgres/spec/typecast/other_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/other_spec' 5 | 6 | describe 'DataObjects::H2 with other (unknown) type' do 7 | it_should_behave_like 'supporting other (unknown) type' 8 | end 9 | -------------------------------------------------------------------------------- /do_postgres/spec/typecast/range_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/range_spec' 5 | 6 | describe 'DataObjects::Postgres with Range' do 7 | it_should_behave_like 'supporting Range' 8 | end 9 | -------------------------------------------------------------------------------- /do_postgres/spec/typecast/string_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/string_spec' 5 | 6 | describe 'DataObjects::Postgres with String' do 7 | it_should_behave_like 'supporting String' 8 | end 9 | -------------------------------------------------------------------------------- /do_postgres/spec/typecast/time_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/time_spec' 5 | 6 | describe 'DataObjects::Postgres with Time' do 7 | it_should_behave_like 'supporting Time' 8 | it_should_behave_like 'supporting sub second Time' 9 | end 10 | -------------------------------------------------------------------------------- /do_postgres/tasks/release.rake: -------------------------------------------------------------------------------- 1 | desc 'Builds all gems (native, binaries for JRuby and Windows)' 2 | task :build_all do 3 | `rake clean` 4 | `rake build` 5 | `rake java gem` 6 | `rake cross native gem RUBY_CC_VERSION=1.8.7:1.9.3:2.0.0:2.1.8:2.2.4:2.3.0` 7 | end 8 | 9 | desc 'Release all gems (native, binaries for JRuby and Windows)' 10 | task :release_all => :build_all do 11 | Dir["pkg/do_postgres-#{DataObjects::Postgres::VERSION}*.gem"].each do |gem_path| 12 | command = "gem push #{gem_path}" 13 | puts "Executing #{command.inspect}:" 14 | sh command 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /do_postgres/tasks/spec.rake: -------------------------------------------------------------------------------- 1 | require 'rspec/core/rake_task' 2 | 3 | RSpec::Core::RakeTask.new(:spec => [:clean, :compile]) do |spec| 4 | spec.pattern = './spec/**/*_spec.rb' 5 | end 6 | 7 | RSpec::Core::RakeTask.new(:rcov => [:clean, :compile]) do |rcov| 8 | rcov.pattern = "./spec/**/*_spec.rb" 9 | rcov.rcov = true 10 | rcov.rcov_opts = File.read('spec/rcov.opts').split(/\s+/) 11 | end 12 | -------------------------------------------------------------------------------- /do_sqlite3/.gitignore: -------------------------------------------------------------------------------- 1 | test.db 2 | test.db-journal 3 | tmp/ 4 | spec/integration/ro_test.db 5 | -------------------------------------------------------------------------------- /do_sqlite3/.rspec: -------------------------------------------------------------------------------- 1 | --format documentation 2 | --colour 3 | -------------------------------------------------------------------------------- /do_sqlite3/Gemfile: -------------------------------------------------------------------------------- 1 | source :rubygems 2 | 3 | path '../' 4 | 5 | gemspec 6 | 7 | platforms :jruby do 8 | gem 'jdbc-sqlite3', '>=3.5.8' 9 | gem 'do_jdbc', '0.10.17' 10 | end 11 | 12 | group :development do # Development dependencies (as in the gemspec) 13 | gem 'rake' 14 | end 15 | -------------------------------------------------------------------------------- /do_sqlite3/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2007 - 2011 Yehuda Katz, Dirkjan Bussink 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /do_sqlite3/Rakefile: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'pathname' 3 | require 'bundler' 4 | require 'rubygems/package_task' 5 | Bundler::GemHelper.install_tasks 6 | 7 | require 'rake' 8 | require 'rake/clean' 9 | 10 | ROOT = Pathname(__FILE__).dirname.expand_path 11 | 12 | require ROOT + 'lib/do_sqlite3/version' 13 | 14 | JRUBY = RUBY_PLATFORM =~ /java/ 15 | IRONRUBY = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ironruby' 16 | WINDOWS = Gem.win_platform? || (JRUBY && ENV_JAVA['os.name'] =~ /windows/i) 17 | SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS']) 18 | BINARY_VERSION = '3071700' 19 | 20 | CLEAN.include(%w[ {tmp,pkg}/ **/*.{o,so,bundle,jar,log,a,gem,dSYM,obj,pdb,exp,DS_Store,rbc,db} ext/do_sqlite3/Makefile ext-java/target ]) 21 | 22 | 23 | if JRUBY 24 | Rake::Task['build'].clear_actions if Rake::Task.task_defined?('build') 25 | Rake::Task['install'].clear_actions if Rake::Task.task_defined?('install') 26 | task :build => [ :java, :gem ] 27 | task :install do 28 | sh "#{Config::CONFIG['RUBY_INSTALL_NAME']} -S gem install pkg/do_sqlite3-#{DataObjects::Sqlite3::VERSION}-java.gem" 29 | end 30 | end 31 | 32 | FileList['tasks/**/*.rake'].each { |task| import task } 33 | -------------------------------------------------------------------------------- /do_sqlite3/buildfile: -------------------------------------------------------------------------------- 1 | # Apache Buildr buildfile for do_sqlite3 2 | # see http://incubator.apache.org/buildr/ for more information on Apache Buildr 3 | require 'buildr' 4 | require 'pathname' 5 | 6 | VERSION_NUMBER = '1.0' 7 | JDBC_SUPPORT = ['data_objects:jdbc:jar:1.0'] 8 | TARGET_DIR = 'pkg/classes' 9 | repositories.remote << 'http://www.ibiblio.org/maven2/' 10 | 11 | define 'do_sqlite3' do 12 | project.version = VERSION_NUMBER 13 | project.group = 'data_objects.rb' 14 | 15 | manifest['Copyright'] = 'Alex Coles (C) 2008-2011' 16 | 17 | compile.using :target => '1.5', :lint => 'all', :deprecation => 'true' 18 | 19 | define 'ext-java' do 20 | package(:jar).clean.include(TARGET_DIR) 21 | 22 | jdbc_support_jar = file('../../do_jdbc/lib/do_jdbc_internal.jar') 23 | jdbc_support = artifact('data_objects:jdbc:jar:1.0').from(jdbc_support_jar) 24 | 25 | compile.into(TARGET_DIR).with(JDBC_SUPPORT) 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /do_sqlite3/ext-java/src/main/java/do_sqlite3/DoSqlite3Service.java: -------------------------------------------------------------------------------- 1 | package do_sqlite3; 2 | 3 | import data_objects.drivers.AbstractDataObjectsService; 4 | import data_objects.drivers.DriverDefinition; 5 | 6 | public class DoSqlite3Service extends AbstractDataObjectsService { 7 | 8 | private final static DriverDefinition driver = new Sqlite3DriverDefinition(); 9 | 10 | /** 11 | * 12 | * @return 13 | */ 14 | @Override 15 | public DriverDefinition getDriverDefinition() { 16 | return driver; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /do_sqlite3/ext/do_sqlite3/compat.h: -------------------------------------------------------------------------------- 1 | #ifndef RUBY_COMPAT_H 2 | #define RUBY_COMPAT_H 3 | 4 | /* 5 | * Rules for better ruby C extensions: 6 | * 7 | * Never use the R macros directly, always use R_ 8 | * 9 | * Never compare with RBASIC(obj)->klass, always use 10 | * rb_obj_is_instance_of() 11 | * 12 | * Never use RHASH(obj)->tbl or RHASH_TBL(). 13 | * 14 | */ 15 | 16 | 17 | // Array 18 | #ifndef RARRAY_PTR 19 | #define RARRAY_PTR(obj) RARRAY(obj)->ptr 20 | #endif 21 | 22 | #ifndef RARRAY_LEN 23 | #define RARRAY_LEN(obj) RARRAY(obj)->len 24 | #endif 25 | 26 | // String 27 | #ifndef RSTRING_PTR 28 | #define RSTRING_PTR(obj) RSTRING(obj)->ptr 29 | #endif 30 | 31 | #ifndef RSTRING_LEN 32 | #define RSTRING_LEN(obj) RSTRING(obj)->len 33 | #endif 34 | 35 | #ifndef rb_str_ptr 36 | #define rb_str_ptr(str) RSTRING_PTR(str) 37 | #endif 38 | 39 | #ifndef rb_str_ptr_readonly 40 | #define rb_str_ptr_readonly(str) RSTRING_PTR(str) 41 | #endif 42 | 43 | #ifndef rb_str_flush 44 | #define rb_str_flush(str) 45 | #endif 46 | 47 | #ifndef rb_str_update 48 | #define rb_str_update(str) 49 | #endif 50 | 51 | #ifndef rb_str_len 52 | #define rb_str_len(str) RSTRING_LEN(str) 53 | #endif 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /do_sqlite3/ext/do_sqlite3/do_common.c: -------------------------------------------------------------------------------- 1 | ../../../data_objects/lib/data_objects/ext/do_common.c -------------------------------------------------------------------------------- /do_sqlite3/ext/do_sqlite3/do_common.h: -------------------------------------------------------------------------------- 1 | ../../../data_objects/lib/data_objects/ext/do_common.h -------------------------------------------------------------------------------- /do_sqlite3/ext/do_sqlite3/do_sqlite3.h: -------------------------------------------------------------------------------- 1 | #ifndef DO_SQLITE3_H 2 | #define DO_SQLITE3_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #ifndef _WIN32 9 | #include 10 | #endif 11 | #include 12 | #include 13 | #include "compat.h" 14 | 15 | #ifndef HAVE_SQLITE3_PREPARE_V2 16 | #define sqlite3_prepare_v2 sqlite3_prepare 17 | #endif 18 | 19 | extern VALUE mDO_Sqlite3; 20 | extern void Init_do_sqlite3_extension(); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /do_sqlite3/ext/do_sqlite3/extconf.rb: -------------------------------------------------------------------------------- 1 | ENV["RC_ARCHS"] = "" if RUBY_PLATFORM =~ /darwin/ 2 | 3 | # Loads mkmf which is used to make makefiles for Ruby extensions 4 | require 'mkmf' 5 | require 'date' 6 | 7 | # Allow for custom compiler to be specified. 8 | RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC'] 9 | 10 | # Use some default search paths 11 | dir_config("sqlite3", ["/usr/local", "/opt/local", "/usr"]) 12 | 13 | # NOTE: use GCC flags unless Visual C compiler is used 14 | $CFLAGS << ' -Wall ' unless RUBY_PLATFORM =~ /mswin/ 15 | 16 | if RUBY_VERSION < '1.8.6' 17 | $CFLAGS << ' -DRUBY_LESS_THAN_186' 18 | end 19 | 20 | unless DateTime.respond_to?(:new!) 21 | $CFLAGS << ' -DHAVE_NO_DATETIME_NEWBANG' 22 | end 23 | 24 | # Do the work 25 | # create_makefile(extension_name) 26 | if have_header( "sqlite3.h" ) && have_library( "sqlite3", "sqlite3_open" ) 27 | have_func("localtime_r") 28 | have_func("gmtime_r") 29 | have_func("sqlite3_prepare_v2") 30 | have_func("sqlite3_open_v2") 31 | have_func("sqlite3_enable_load_extension") 32 | 33 | create_makefile('do_sqlite3/do_sqlite3') 34 | end 35 | -------------------------------------------------------------------------------- /do_sqlite3/lib/do_sqlite3/transaction.rb: -------------------------------------------------------------------------------- 1 | 2 | module DataObjects 3 | 4 | module Sqlite3 5 | 6 | class Transaction < DataObjects::Transaction 7 | 8 | def begin_prepared 9 | raise NotImplementedError 10 | end 11 | 12 | def commit_prepared 13 | raise NotImplementedError 14 | end 15 | 16 | def rollback_prepared 17 | raise NotImplementedError 18 | end 19 | 20 | def prepare 21 | raise NotImplementedError 22 | end 23 | 24 | end 25 | 26 | end 27 | 28 | end 29 | -------------------------------------------------------------------------------- /do_sqlite3/lib/do_sqlite3/version.rb: -------------------------------------------------------------------------------- 1 | module DataObjects 2 | module Sqlite3 3 | VERSION = '0.10.17' 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /do_sqlite3/spec/command_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/command_spec' 5 | 6 | describe DataObjects::Sqlite3::Command do 7 | it_should_behave_like 'a Command' 8 | end 9 | -------------------------------------------------------------------------------- /do_sqlite3/spec/connection_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/connection_spec' 5 | 6 | describe DataObjects::Sqlite3::Connection do 7 | 8 | before :all do 9 | @driver = CONFIG.scheme 10 | @user = CONFIG.user 11 | @password = CONFIG.pass 12 | @host = CONFIG.host 13 | @port = CONFIG.port 14 | @database = CONFIG.database 15 | end 16 | 17 | it_should_behave_like 'a Connection' 18 | it_should_behave_like 'a Connection via JDNI' if JRUBY 19 | it_should_behave_like 'a Connection with JDBC URL support' if JRUBY 20 | 21 | unless JRUBY 22 | 23 | describe 'connecting with busy timeout' do 24 | 25 | it 'connects with a valid timeout' do 26 | DataObjects::Connection.new("#{CONFIG.uri}?busy_timeout=200").should_not be_nil 27 | end 28 | 29 | it 'raises an error when passed an invalid value' do 30 | lambda { DataObjects::Connection.new("#{CONFIG.uri}?busy_timeout=stuff") }. 31 | should raise_error(ArgumentError) 32 | end 33 | 34 | end 35 | end 36 | 37 | end 38 | -------------------------------------------------------------------------------- /do_sqlite3/spec/encoding_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/encoding_spec' 5 | 6 | describe DataObjects::Sqlite3::Connection do 7 | it_should_behave_like 'returning correctly encoded strings for the default database encoding' 8 | it_should_behave_like 'returning correctly encoded strings for the default internal encoding' unless JRUBY 9 | end 10 | -------------------------------------------------------------------------------- /do_sqlite3/spec/error/sql_error_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/error/sql_error_spec' 5 | 6 | describe 'DataObjects::Sqlite3 raising SQLError' do 7 | # This fails for now, need to think of a query that also exposes the issue on sqlite :S 8 | # it_should_behave_like 'raising a SQLError' 9 | end 10 | -------------------------------------------------------------------------------- /do_sqlite3/spec/rcov.opts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datamapper/do/16564e6dba587e92e41aba376b46ef765f3bffea/do_sqlite3/spec/rcov.opts -------------------------------------------------------------------------------- /do_sqlite3/spec/reader_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/reader_spec' 5 | 6 | describe DataObjects::Sqlite3::Reader do 7 | it_should_behave_like 'a Reader' 8 | end 9 | -------------------------------------------------------------------------------- /do_sqlite3/spec/result_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/result_spec' 5 | 6 | # splitting the descibe into two separate declaration avoids 7 | # concurrent execution of the "it_should_behave_like ....." calls 8 | # which would lock the database 9 | 10 | # TODO 11 | # the locked database created a deadlock which is worth exploring since 12 | # such situation could appear in the wild too 13 | describe DataObjects::Sqlite3::Result do 14 | it_should_behave_like 'a Result' 15 | end 16 | 17 | describe DataObjects::Sqlite3::Result do 18 | it_should_behave_like 'a Result which returns inserted key with sequences' 19 | end 20 | -------------------------------------------------------------------------------- /do_sqlite3/spec/typecast/array_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/array_spec' 5 | 6 | describe 'DataObjects::Sqlite3 with Array' do 7 | it_should_behave_like 'supporting Array' 8 | end 9 | -------------------------------------------------------------------------------- /do_sqlite3/spec/typecast/bigdecimal_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/bigdecimal_spec' 5 | 6 | # Sqlite3 doesn't support decimals natively, so autocasting is not available: 7 | # http://www.sqlite.org/datatype3.html 8 | 9 | describe 'DataObjects::Sqlite3 with BigDecimal' do 10 | it_should_behave_like 'supporting BigDecimal' 11 | end 12 | -------------------------------------------------------------------------------- /do_sqlite3/spec/typecast/boolean_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/boolean_spec' 5 | 6 | # Sqlite3 doesn't support booleans natively, so autocasting is not available: 7 | # http://www.sqlite.org/datatype3.html 8 | 9 | describe 'DataObjects::Sqlite3 with Boolean' do 10 | it_should_behave_like 'supporting Boolean' 11 | end 12 | -------------------------------------------------------------------------------- /do_sqlite3/spec/typecast/byte_array_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/byte_array_spec' 5 | 6 | describe 'DataObjects::Sqlite3 with ByteArray' do 7 | it_should_behave_like 'supporting ByteArray' 8 | end 9 | -------------------------------------------------------------------------------- /do_sqlite3/spec/typecast/class_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/class_spec' 5 | 6 | describe 'DataObjects::Sqlite3 with Class' do 7 | it_should_behave_like 'supporting Class' 8 | end 9 | -------------------------------------------------------------------------------- /do_sqlite3/spec/typecast/date_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/date_spec' 5 | 6 | # Sqlite3 doesn't support dates natively, so autocasting is not available: 7 | # http://www.sqlite.org/datatype3.html 8 | 9 | describe 'DataObjects::Sqlite3 with Date' do 10 | it_should_behave_like 'supporting Date' 11 | end 12 | -------------------------------------------------------------------------------- /do_sqlite3/spec/typecast/datetime_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/datetime_spec' 5 | 6 | # Sqlite3 doesn't support datetimes natively, so autocasting is not available: 7 | # http://www.sqlite.org/datatype3.html 8 | 9 | describe 'DataObjects::Sqlite3 with DateTime' do 10 | it_should_behave_like 'supporting DateTime' 11 | end 12 | -------------------------------------------------------------------------------- /do_sqlite3/spec/typecast/float_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/float_spec' 5 | 6 | describe 'DataObjects::Sqlite3 with Float' do 7 | it_should_behave_like 'supporting Float' 8 | end 9 | 10 | describe 'DataObjects::Sqlite3 with Float' do 11 | it_should_behave_like 'supporting Float autocasting' 12 | end 13 | -------------------------------------------------------------------------------- /do_sqlite3/spec/typecast/integer_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/integer_spec' 5 | 6 | describe 'DataObjects::Sqlite3 with Integer' do 7 | it_should_behave_like 'supporting Integer' 8 | end 9 | -------------------------------------------------------------------------------- /do_sqlite3/spec/typecast/nil_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/nil_spec' 5 | 6 | # splitting the descibe into two separate declaration avoids 7 | # concurrent execution of the "it_should_behave_like ....." calls 8 | # which would lock the database 9 | 10 | describe 'DataObjects::Sqlite3 with Nil' do 11 | it_should_behave_like 'supporting Nil' 12 | end 13 | 14 | describe 'DataObjects::Sqlite3 with Nil' do 15 | it_should_behave_like 'supporting writing an Nil' 16 | end 17 | 18 | describe 'DataObjects::Sqlite3 with Nil' do 19 | it_should_behave_like 'supporting Nil autocasting' 20 | end 21 | -------------------------------------------------------------------------------- /do_sqlite3/spec/typecast/other_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/other_spec' 5 | 6 | describe 'DataObjects::H2 with other (unknown) type' do 7 | it_should_behave_like 'supporting other (unknown) type' 8 | end 9 | -------------------------------------------------------------------------------- /do_sqlite3/spec/typecast/range_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/range_spec' 5 | 6 | describe 'DataObjects::Sqlite3 with Range' do 7 | it_should_behave_like 'supporting Range' 8 | end 9 | -------------------------------------------------------------------------------- /do_sqlite3/spec/typecast/string_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/string_spec' 5 | 6 | describe 'DataObjects::Sqlite3 with String' do 7 | it_should_behave_like 'supporting String' 8 | end 9 | -------------------------------------------------------------------------------- /do_sqlite3/spec/typecast/time_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/time_spec' 5 | 6 | describe 'DataObjects::Sqlite3 with Time' do 7 | it_should_behave_like 'supporting Time' 8 | it_should_behave_like 'supporting sub second Time' unless JRUBY 9 | end 10 | -------------------------------------------------------------------------------- /do_sqlite3/tasks/release.rake: -------------------------------------------------------------------------------- 1 | desc 'Builds all gems (native, binaries for JRuby and Windows)' 2 | task :build_all do 3 | `rake clean` 4 | `rake build` 5 | `rake java gem` 6 | `rake cross native gem RUBY_CC_VERSION=1.8.7:1.9.3:2.0.0:2.1.8:2.2.4:2.3.0` 7 | end 8 | 9 | desc 'Release all gems (native, binaries for JRuby and Windows)' 10 | task :release_all => :build_all do 11 | Dir["pkg/do_sqlite3-#{DataObjects::Sqlite3::VERSION}*.gem"].each do |gem_path| 12 | command = "gem push #{gem_path}" 13 | puts "Executing #{command.inspect}:" 14 | sh command 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /do_sqlite3/tasks/spec.rake: -------------------------------------------------------------------------------- 1 | require 'rspec/core/rake_task' 2 | 3 | RSpec::Core::RakeTask.new(:spec => [:clean, :compile]) do |spec| 4 | spec.pattern = './spec/**/*_spec.rb' 5 | end 6 | 7 | RSpec::Core::RakeTask.new(:rcov => [:clean, :compile]) do |rcov| 8 | rcov.pattern = "./spec/**/*_spec.rb" 9 | rcov.rcov = true 10 | rcov.rcov_opts = File.read('spec/rcov.opts').split(/\s+/) 11 | end 12 | -------------------------------------------------------------------------------- /do_sqlserver/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datamapper/do/16564e6dba587e92e41aba376b46ef765f3bffea/do_sqlserver/.gitignore -------------------------------------------------------------------------------- /do_sqlserver/.rspec: -------------------------------------------------------------------------------- 1 | --format documentation 2 | --colour 3 | -------------------------------------------------------------------------------- /do_sqlserver/FAQS.markdown: -------------------------------------------------------------------------------- 1 | FAQS 2 | ==== 3 | 4 | * Can I use Microsoft's SQL Server driver instead of jTDS? 5 | 6 | No, not currently. Currently the DataObjects Driver implementation is tied not 7 | only to a relational database, but to its JDBC driver implementation. You could 8 | create an alternate database implementation. 9 | -------------------------------------------------------------------------------- /do_sqlserver/Gemfile: -------------------------------------------------------------------------------- 1 | source :rubygems 2 | 3 | path '../' 4 | 5 | gemspec 6 | 7 | group :development do # Development dependencies (as in the gemspec) 8 | gem 'rake' 9 | end 10 | -------------------------------------------------------------------------------- /do_sqlserver/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 Clifford Heath 2 | Copyright (c) 2009 - 2011 Alex Coles 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /do_sqlserver/Rakefile: -------------------------------------------------------------------------------- 1 | require 'pathname' 2 | require 'rubygems' 3 | require 'bundler' 4 | require 'rubygems/package_task' 5 | Bundler::GemHelper.install_tasks 6 | 7 | require 'rake' 8 | require 'rake/clean' 9 | 10 | ROOT = Pathname(__FILE__).dirname.expand_path 11 | 12 | require ROOT + 'lib/do_sqlserver/version' 13 | 14 | JRUBY = RUBY_PLATFORM =~ /java/ 15 | IRONRUBY = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ironruby' 16 | WINDOWS = Gem.win_platform? || (JRUBY && ENV_JAVA['os.name'] =~ /windows/i) 17 | SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS']) 18 | 19 | CLEAN.include(%w[ {tmp,pkg}/ **/*.{o,so,bundle,jar,log,a,gem,dSYM,obj,pdb,exp,DS_Store,rbc,db} ext-java/target ]) 20 | 21 | 22 | Rake::Task['build'].clear_actions if Rake::Task.task_defined?('build') 23 | task :build => [ :java, :gem ] 24 | 25 | FileList['tasks/**/*.rake'].each { |task| import task } 26 | -------------------------------------------------------------------------------- /do_sqlserver/buildfile: -------------------------------------------------------------------------------- 1 | # Apache Buildr buildfile for do_sqlserver 2 | # see http://incubator.apache.org/buildr/ for more information on Apache Buildr 3 | require 'buildr' 4 | require 'pathname' 5 | 6 | VERSION_NUMBER = '1.0' 7 | JDBC_SUPPORT = ['data_objects:jdbc:jar:1.0'] 8 | TARGET_DIR = 'pkg/classes' 9 | repositories.remote << 'http://www.ibiblio.org/maven2/' 10 | 11 | define 'do_sqlserver' do 12 | project.version = VERSION_NUMBER 13 | project.group = 'data_objects.rb' 14 | 15 | manifest['Copyright'] = 'Raimonds Simanovskis (C) 2009' 16 | 17 | compile.using :target => '1.5', :lint => 'all', :deprecation => 'true' 18 | 19 | define 'ext-java' do 20 | package(:jar).clean.include(TARGET_DIR) 21 | 22 | jdbc_support_jar = file('../../do_jdbc/lib/do_jdbc_internal.jar') 23 | jdbc_support = artifact('data_objects:jdbc:jar:1.0').from(jdbc_support_jar) 24 | 25 | compile.into(TARGET_DIR).with(JDBC_SUPPORT) 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /do_sqlserver/ext-java/src/main/java/do_sqlserver/DoSqlserverService.java: -------------------------------------------------------------------------------- 1 | package do_sqlserver; 2 | 3 | import data_objects.drivers.AbstractDataObjectsService; 4 | import data_objects.drivers.DriverDefinition; 5 | 6 | // this class must be named DoSqlserverService (and not DoSqlServerService) 7 | // for the extension to be loaded correctly (alternatively, we could add an 8 | // underscore to the extension JAR name). 9 | public class DoSqlserverService extends AbstractDataObjectsService { 10 | 11 | private final static DriverDefinition driver = new SqlServerDriverDefinition(); 12 | 13 | /** 14 | * 15 | * @return 16 | */ 17 | @Override 18 | public DriverDefinition getDriverDefinition() { 19 | return driver; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /do_sqlserver/ext/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | mkmf.log 3 | -------------------------------------------------------------------------------- /do_sqlserver/lib/do_sqlserver/transaction.rb: -------------------------------------------------------------------------------- 1 | module DataObjects 2 | 3 | module SqlServer 4 | 5 | class Transaction < DataObjects::Transaction 6 | 7 | def begin 8 | connection.instance_variable_get("@connection").autocommit = false 9 | end 10 | 11 | def commit 12 | connection.instance_variable_get("@connection").commit 13 | ensure 14 | connection.instance_variable_get("@connection").autocommit = true 15 | end 16 | 17 | def rollback 18 | connection.instance_variable_get("@connection").rollback 19 | ensure 20 | connection.instance_variable_get("@connection").autocommit = true 21 | end 22 | 23 | def rollback_prepared 24 | # TODO: what should be done differently? 25 | rollback 26 | end 27 | 28 | def prepare 29 | # TODO: what should be done here? 30 | end 31 | 32 | end 33 | 34 | end 35 | 36 | end 37 | -------------------------------------------------------------------------------- /do_sqlserver/lib/do_sqlserver/version.rb: -------------------------------------------------------------------------------- 1 | module DataObjects 2 | module SqlServer 3 | VERSION = '0.10.17' 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /do_sqlserver/spec/command_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/command_spec' 5 | 6 | describe DataObjects::SqlServer::Command do 7 | it_should_behave_like 'a Command' 8 | it_should_behave_like 'a Command with async' 9 | end 10 | -------------------------------------------------------------------------------- /do_sqlserver/spec/connection_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/connection_spec' 5 | 6 | describe DataObjects::SqlServer::Connection do 7 | 8 | before :all do 9 | @driver = CONFIG.scheme 10 | @user = CONFIG.user 11 | @password = CONFIG.pass 12 | @host = CONFIG.host 13 | @port = CONFIG.port 14 | @database = CONFIG.database 15 | end 16 | 17 | it_should_behave_like 'a Connection' 18 | #it_should_behave_like 'a Connection with authentication support' 19 | it_should_behave_like 'a Connection with JDBC URL support' if JRUBY 20 | it_should_behave_like 'a Connection via JDNI' if JRUBY 21 | end 22 | -------------------------------------------------------------------------------- /do_sqlserver/spec/encoding_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/encoding_spec' 5 | 6 | describe DataObjects::SqlServer::Connection do 7 | it_should_behave_like 'a driver supporting different encodings' 8 | end 9 | -------------------------------------------------------------------------------- /do_sqlserver/spec/rcov.opts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datamapper/do/16564e6dba587e92e41aba376b46ef765f3bffea/do_sqlserver/spec/rcov.opts -------------------------------------------------------------------------------- /do_sqlserver/spec/reader_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/reader_spec' 5 | 6 | describe DataObjects::SqlServer::Reader do 7 | it_should_behave_like 'a Reader' 8 | end 9 | -------------------------------------------------------------------------------- /do_sqlserver/spec/result_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) 4 | require 'data_objects/spec/shared/result_spec' 5 | 6 | # splitting the descibe into two separate declaration avoids 7 | # concurrent execution of the "it_should_behave_like ....." 8 | # needed by some databases (sqlite3) 9 | 10 | describe DataObjects::SqlServer::Result do 11 | it_should_behave_like 'a Result' 12 | end 13 | 14 | describe DataObjects::SqlServer::Result do 15 | it_should_behave_like 'a Result which returns inserted key with sequences' 16 | end 17 | -------------------------------------------------------------------------------- /do_sqlserver/spec/typecast/array_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/array_spec' 5 | 6 | describe 'DataObjects::SqlServer with Array' do 7 | it_should_behave_like 'supporting Array' 8 | end 9 | -------------------------------------------------------------------------------- /do_sqlserver/spec/typecast/bigdecimal_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/bigdecimal_spec' 5 | 6 | describe 'DataObjects::SqlServer with BigDecimal' do 7 | it_should_behave_like 'supporting BigDecimal' 8 | it_should_behave_like 'supporting BigDecimal autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_sqlserver/spec/typecast/boolean_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/boolean_spec' 5 | 6 | describe 'DataObjects::SqlServer with Boolean' do 7 | it_should_behave_like 'supporting Boolean' 8 | it_should_behave_like 'supporting Boolean autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_sqlserver/spec/typecast/class_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/class_spec' 5 | 6 | describe 'DataObjects::SqlServer with Class' do 7 | it_should_behave_like 'supporting Class' 8 | end 9 | -------------------------------------------------------------------------------- /do_sqlserver/spec/typecast/date_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/date_spec' 5 | 6 | describe 'DataObjects::SqlServer with Date' do 7 | it_should_behave_like 'supporting Date' 8 | 9 | # SqlServer will cast DATE type to Time 10 | # it_should_behave_like 'supporting Date autocasting' 11 | end 12 | -------------------------------------------------------------------------------- /do_sqlserver/spec/typecast/datetime_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/datetime_spec' 5 | 6 | describe 'DataObjects::SqlServer with DateTime' do 7 | it_should_behave_like 'supporting DateTime' 8 | # it_should_behave_like 'supporting DateTime autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_sqlserver/spec/typecast/float_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/float_spec' 5 | 6 | describe 'DataObjects::SqlServer with Float' do 7 | it_should_behave_like 'supporting Float' 8 | # it_should_behave_like 'supporting Float autocasting' 9 | end 10 | -------------------------------------------------------------------------------- /do_sqlserver/spec/typecast/integer_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/integer_spec' 5 | 6 | describe 'DataObjects::SqlServer with Integer' do 7 | it_should_behave_like 'supporting Integer' 8 | end 9 | -------------------------------------------------------------------------------- /do_sqlserver/spec/typecast/nil_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/nil_spec' 5 | 6 | describe 'DataObjects::SqlServer with Nil' do 7 | it_should_behave_like 'supporting Nil' 8 | it_should_behave_like 'supporting writing an Nil' 9 | it_should_behave_like 'supporting Nil autocasting' 10 | end 11 | -------------------------------------------------------------------------------- /do_sqlserver/spec/typecast/other_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/other_spec' 5 | 6 | describe 'DataObjects::H2 with other (unknown) type' do 7 | it_should_behave_like 'supporting other (unknown) type' 8 | end 9 | -------------------------------------------------------------------------------- /do_sqlserver/spec/typecast/range_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/range_spec' 5 | 6 | describe 'DataObjects::SqlServer with Range' do 7 | it_should_behave_like 'supporting Range' 8 | end 9 | -------------------------------------------------------------------------------- /do_sqlserver/spec/typecast/string_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/string_spec' 5 | 6 | describe 'DataObjects::SqlServer with String' do 7 | it_should_behave_like 'supporting String' 8 | end 9 | -------------------------------------------------------------------------------- /do_sqlserver/spec/typecast/time_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) 4 | require 'data_objects/spec/shared/typecast/time_spec' 5 | 6 | describe 'DataObjects::SqlServer with Time' do 7 | it_should_behave_like 'supporting Time' 8 | end 9 | -------------------------------------------------------------------------------- /do_sqlserver/tasks/compile.rake: -------------------------------------------------------------------------------- 1 | begin 2 | gem 'rake-compiler', '~>0.7' 3 | require 'rake/javaextensiontask' 4 | 5 | def gemspec 6 | @clean_gemspec ||= Gem::Specification::load(File.expand_path('../../do_sqlserver.gemspec', __FILE__)) 7 | end 8 | 9 | Rake::JavaExtensionTask.new('do_sqlserver', gemspec) do |ext| 10 | ext.ext_dir = 'ext-java/src/main/java' 11 | ext.lib_dir = 'lib/do_sqlserver' 12 | ext.debug = ENV.has_key?('DO_JAVA_DEBUG') && ENV['DO_JAVA_DEBUG'] 13 | ext.classpath = '../do_jdbc/lib/do_jdbc_internal.jar' 14 | end 15 | 16 | # do_sqlserver is only available for JRuby: the normal behaviour of 17 | # rake-compiler is to only chain 'compile:PLATFORM' tasks to 'compile' where 18 | # PLATFORM is the platform of the current interpreter (i.e. 'compile:java' 19 | # to 'compile' only if running on JRuby). However, we always want to compile 20 | # for Java, even if running from MRI. 21 | task 'compile:do_sqlserver' => ['compile:do_sqlserver:java'] 22 | task 'compile' => ['compile:java'] 23 | 24 | rescue LoadError 25 | warn "To compile, install rake-compiler (gem install rake-compiler)" 26 | end 27 | -------------------------------------------------------------------------------- /do_sqlserver/tasks/release.rake: -------------------------------------------------------------------------------- 1 | desc 'Builds all gems (native, binaries for JRuby and Windows)' 2 | task :build_all do 3 | `rake clean` 4 | `rake java gem` 5 | end 6 | 7 | desc 'Release all gems (native, binaries for JRuby and Windows)' 8 | task :release_all => :build_all do 9 | Dir["pkg/do_sqlserver-#{DataObjects::SqlServer::VERSION}*.gem"].each do |gem_path| 10 | command = "gem push #{gem_path}" 11 | puts "Executing #{command.inspect}:" 12 | sh command 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /do_sqlserver/tasks/spec.rake: -------------------------------------------------------------------------------- 1 | require 'rspec/core/rake_task' 2 | 3 | RSpec::Core::RakeTask.new(:spec => [:clean, :compile]) do |spec| 4 | spec.pattern = './spec/**/*_spec.rb' 5 | end 6 | 7 | RSpec::Core::RakeTask.new(:rcov => [:clean, :compile]) do |rcov| 8 | rcov.pattern = "./spec/**/*_spec.rb" 9 | rcov.rcov = true 10 | rcov.rcov_opts = File.read('spec/rcov.opts').split(/\s+/) 11 | end 12 | -------------------------------------------------------------------------------- /jdbc_drivers/README.developers: -------------------------------------------------------------------------------- 1 | README for Developers 2 | ===================== 3 | 4 | ** NOTE ** These instructions are deprecated. We now use the drivers bundled 5 | as Gems provided by the ActiveRecord-JDBC project. Only drivers that that 6 | project does not yet provide should be provided in this directory. 7 | 8 | # make sure RUBY_HOME is set 9 | 10 | # builder 1.3.2 is tied to version specific dependencies 11 | jruby -S gem install jruby-openssl -v 0.2 12 | jruby -S gem install hoe -v 1.6.0 13 | jruby -S gem install buildr 14 | 15 | # you'll also need to have data_objects installed 16 | jruby -S gem install data_object-0.9.x.gem 17 | 18 | # To update JDBC drivers from Maven Repository: 19 | jruby -S buildr do_jdbc:update_drivers 20 | 21 | # You can then go to the driver directory 22 | # you want and install the gem 23 | jruby -S rake -------------------------------------------------------------------------------- /jdbc_drivers/sqlserver/README.markdown: -------------------------------------------------------------------------------- 1 | # Sql Server JDBC Driver 2 | 3 | This is a Sql Server JDBC driver packaged as gem for convenient installation in JRuby. 4 | 5 | The do_sqlserver driver extension should automatically download and install this 6 | gem for you, by virtue of the RubyGems requirement system. 7 | 8 | If you want to load this driver directly: 9 | 10 | ```ruby 11 | require 'do_jdbc/sqlserver' 12 | ``` 13 | 14 | to make the driver accessible to JDBC and DataObjects code running in JRuby. 15 | 16 | ## Copyright and Licensing 17 | 18 | This gem bundles the jtds JDBC Driver, http://jtds.sourceforge.net/ 19 | 20 | The jtds JDBC Driver is available under the terms of the LGPL License. See 21 | http://www.gnu.org/copyleft/lesser.html for more details. 22 | -------------------------------------------------------------------------------- /jdbc_drivers/sqlserver/Rakefile: -------------------------------------------------------------------------------- 1 | require 'pathname' 2 | require 'rubygems' 3 | require 'rake' 4 | require 'rake/clean' 5 | 6 | ROOT = Pathname(__FILE__).dirname.expand_path 7 | 8 | require ROOT + 'lib/do_jdbc/sqlserver_version' 9 | 10 | JRUBY = RUBY_PLATFORM =~ /java/ 11 | WINDOWS = Gem.win_platform? || (JRUBY && ENV_JAVA['os.name'] =~ /windows/i) 12 | SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS']) 13 | 14 | CLEAN.include(%w[ pkg/ *.gem *.gemspec .config ]) 15 | 16 | warn "SQL Server JDBC (jTDS) Driver is only for use with JRuby" unless RUBY_PLATFORM =~ /java/ 17 | 18 | begin 19 | require 'jeweler' 20 | 21 | Jeweler::Tasks.new do |gem| 22 | gem.name = 'do-jdbc_sqlserver' 23 | gem.version = DataObjects::Jdbc::SqlServer::VERSION 24 | gem.summary = 'SQL Server JDBC (jTDS) Driver' 25 | gem.description = 'JDBC Driver for SQL Server (jTDS), packaged as a Gem' 26 | gem.platform = 'java' 27 | 28 | gem.rubyforge_project = 'dorb' 29 | 30 | gem.authors = ['alin_sinpalean', 'bheineman', 'ickzon'] 31 | gem.email = '' 32 | gem.homepage = 'http://jtds.sourceforge.net/' 33 | end 34 | 35 | Jeweler::GemcutterTasks.new 36 | 37 | task :default => [ :install ] 38 | 39 | rescue LoadError 40 | puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler' 41 | end 42 | -------------------------------------------------------------------------------- /jdbc_drivers/sqlserver/lib/do_jdbc/sqlserver.rb: -------------------------------------------------------------------------------- 1 | if RUBY_PLATFORM =~ /java/ 2 | require 'pathname' 3 | require Pathname(__FILE__).dirname.expand_path + 'sqlserver_version' 4 | require Pathname(__FILE__).dirname.expand_path.parent + "#{DataObjects::Jdbc::SqlServer::JAR_NAME}" 5 | else 6 | warn "do_jdbc-sqlserver is only for use with JRuby" 7 | end 8 | -------------------------------------------------------------------------------- /jdbc_drivers/sqlserver/lib/do_jdbc/sqlserver_version.rb: -------------------------------------------------------------------------------- 1 | module DataObjects 2 | module Jdbc 3 | module SqlServer 4 | VERSION = '1.2.4' 5 | JAR_NAME = "jtds-#{DataObjects::Jdbc::SqlServer::VERSION}.jar" 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /jdbc_drivers/sqlserver/lib/jtds-1.2.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datamapper/do/16564e6dba587e92e41aba376b46ef765f3bffea/jdbc_drivers/sqlserver/lib/jtds-1.2.4.jar --------------------------------------------------------------------------------