Changeset: 93385d665e3d for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=93385d665e3d Added Files: clients/ruby/Tests/All clients/ruby/Tests/rubytest.rb clients/ruby/Tests/rubytest.stable.err clients/ruby/Tests/rubytest.stable.out clients/ruby/doc/readme.txt clients/ruby/lib/example.rb clients/ruby/ruby-monetdb-sql-0.2.gemspec Removed Files: clients/ruby/adapter/Makefile.ag clients/ruby/adapter/active_record/connection_adapters/monetdb_adapter.rb clients/ruby/adapter/activerecord-monetdb-adapter-0.1.gemspec clients/ruby/adapter/lib/active_record/connection_adapters/monetdb_adapter.rb clients/ruby/doc/rails.txt clients/ruby/examples/activerecord.rb clients/ruby/examples/standalone.rb clients/ruby/lib/demo.rb clients/ruby/ruby-monetdb-sql-0.1.gemspec Modified Files: .hgignore clients/ruby/lib/MonetDB.rb clients/ruby/lib/MonetDBConnection.rb clients/ruby/lib/MonetDBData.rb clients/ruby/lib/test/test_capabilities.rb testing/Mtest.py.in Branch: default Log Message:
Ruby interface extension / Added Ruby tests / Removed activerecord integration diffs (truncated from 2842 to 300 lines): diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -100,6 +100,9 @@ NT/unistd.h MacOSX/build MacOSX/usr +# Build directory +BUILD + syntax: regexp ^java/build$ syntax: regexp diff --git a/clients/ruby/Tests/All b/clients/ruby/Tests/All new file mode 100644 --- /dev/null +++ b/clients/ruby/Tests/All @@ -0,0 +1,1 @@ +rubytest.rb \ No newline at end of file diff --git a/clients/ruby/Tests/rubytest.rb b/clients/ruby/Tests/rubytest.rb new file mode 100644 --- /dev/null +++ b/clients/ruby/Tests/rubytest.rb @@ -0,0 +1,90 @@ +require 'minitest/autorun' +require_relative '../lib/MonetDB' + +describe MonetDB do + before do + portnumber = ARGV[0] || 50000 + dbname = ARGV[1] || "mTests_." + + @database_connection = MonetDB.new + @database_connection.connect(user = "monetdb", passwd = "monetdb", lang = "sql", host="127.0.0.1", port = portnumber, database_connection_name = dbname, auth_type = "SHA1") + + @database_connection.query("CREATE TABLE testtable (id INTEGER, integertest INTEGER, stringtest CHARACTER LARGE OBJECT)") + @database_connection.query("INSERT INTO testtable (id, integertest, stringtest) VALUES (1, 42, 'foo')"); + @database_connection.query("INSERT INTO testtable (id, integertest, stringtest) VALUES (2, 43, 'bar baz')"); + + @query_result = @database_connection.query("SELECT * FROM testtable t"); + end + + after do + @database_connection.query("DROP TABLE testtable"); + end + + describe "Monet DB interface" do + it " can fetch all result items from a query in a hash" do + @query_result.fetch_all_as_column_hash.must_equal({"id"=>[1, 2], "stringtest"=>["foo", "bar baz"], "integertest"=>[42, 43]}) + end + + it " can fetch a record from a query in a hash" do + @query_result.fetch_hash.must_equal({"id"=>1, "stringtest"=>"foo", "integertest"=>42}) + end + + it " can iterate through all records in hash" do + result_collection = [] + @query_result.each_record_as_hash { |record| result_collection.push(record) } + result_collection.must_equal([{ "id" => 1, "stringtest" => "foo", "integertest" => 42 }, { "id" => 2, "stringtest" => "bar baz", "integertest" => 43 }]) + end + + it " can fetch a result record" do + @query_result.fetch.must_equal([1, 42, "foo"]) + end + + it " can fetch all records" do + @query_result.fetch_all.must_equal([[1, 42, "foo"], [2, 43, "bar baz"]]) + end + + it " can count the number of resulting rows from a query" do + @query_result.num_rows.must_equal(2) + end + + it " can count the number of resulting fields from a query" do + @query_result.num_fields.must_equal(3) + end + + it " can get the name of fields from a query" do + @query_result.name_fields.must_equal(["id", "integertest", "stringtest"]) + end + + it " can get the type of fields from a query" do + @query_result.type_fields.must_equal({"id"=>"int", "stringtest"=>"clob", "integertest"=>"int"}) + end + + it " can get all values by column name" do + @query_result.fetch_by_column_name("id").must_equal([1, 2]) + end + + it " can iterate through all records" do + result_collection = [] + @query_result.each_record { |record| result_collection.push(record) } + result_collection.must_equal([[1, 42, "foo"], [2, 43, "bar baz"]]) + end + end +end + +# Overwrite some methods in minitest to prevent tests from failing over difference in time and seed reports +module Minitest + class SummaryReporter + def start + super + + io.puts "# Running:" + + self.sync = io.respond_to? :"sync=" # stupid emacs + self.old_sync, io.sync = io.sync, true if self.sync + end + + def statistics + # do nothing to prevent tests from failing over difference in time reports + end + end +end \ No newline at end of file diff --git a/clients/ruby/Tests/rubytest.stable.err b/clients/ruby/Tests/rubytest.stable.err new file mode 100644 --- /dev/null +++ b/clients/ruby/Tests/rubytest.stable.err @@ -0,0 +1,37 @@ +stderr of test 'rubytest` in directory 'clients/ruby` itself: + + +# 11:46:08 > +# 11:46:08 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=33382" "--set" "mapi_usock=/var/tmp/mtest-44013/.s.monetdb.33382" "--set" "monet_prompt=" "--forcemito" "--set" "mal_listing=2" "--dbpath=/Users/rkoopmanschap/projects/MonetDB-installation/var/MonetDB/mTests_clients_ruby" "--set" "mal_listing=0" "--set" "embedded_r=yes" +# 11:46:08 > + +# builtin opt gdk_dbpath = /Users/rkoopmanschap/projects/MonetDB-installation/var/monetdb5/dbfarm/demo +# builtin opt gdk_debug = 0 +# builtin opt gdk_vmtrim = no +# builtin opt monet_prompt = > +# builtin opt monet_daemon = no +# builtin opt mapi_port = 50000 +# builtin opt mapi_open = false +# builtin opt mapi_autosense = false +# builtin opt sql_optimizer = default_pipe +# builtin opt sql_debug = 0 +# cmdline opt gdk_nr_threads = 0 +# cmdline opt mapi_open = true +# cmdline opt mapi_port = 33382 +# cmdline opt mapi_usock = /var/tmp/mtest-44013/.s.monetdb.33382 +# cmdline opt monet_prompt = +# cmdline opt mal_listing = 2 +# cmdline opt gdk_dbpath = /Users/rkoopmanschap/projects/MonetDB-installation/var/MonetDB/mTests_clients_ruby +# cmdline opt mal_listing = 0 +# cmdline opt embedded_r = yes +# cmdline opt gdk_debug = 536870922 + +# 11:46:09 > +# 11:46:09 > "ruby" "rubytest.rb" "33382" "mTests_clients_ruby" +# 11:46:09 > + + +# 11:46:09 > +# 11:46:09 > "Done." +# 11:46:09 > + diff --git a/clients/ruby/Tests/rubytest.stable.out b/clients/ruby/Tests/rubytest.stable.out new file mode 100644 --- /dev/null +++ b/clients/ruby/Tests/rubytest.stable.out @@ -0,0 +1,75 @@ +stdout of test 'rubytest` in directory 'clients/ruby` itself: + + +# 11:46:08 > +# 11:46:08 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=33382" "--set" "mapi_usock=/var/tmp/mtest-44013/.s.monetdb.33382" "--set" "monet_prompt=" "--forcemito" "--set" "mal_listing=2" "--dbpath=/Users/rkoopmanschap/projects/MonetDB-installation/var/MonetDB/mTests_clients_ruby" "--set" "mal_listing=0" "--set" "embedded_r=yes" +# 11:46:08 > + +# MonetDB 5 server v11.22.0 +# This is an unreleased version +# Serving database 'mTests_clients_ruby', using 4 threads +# Compiled for x86_64-apple-darwin14.5.0/64bit with 64bit OIDs and 128bit integers dynamically linked +# Found 16.000 GiB available main-memory. +# Copyright (c) 1993-July 2008 CWI. +# Copyright (c) August 2008-2015 MonetDB B.V., all rights reserved +# Visit http://www.monetdb.org/ for further information +# Listening for connection requests on mapi:monetdb://gup-129-196.cwi.nl:33382/ +# Listening for UNIX domain connection requests on mapi:monetdb:///var/tmp/mtest-44013/.s.monetdb.33382 +# MonetDB/GIS module loaded +# Start processing logs sql/sql_logs version 52200 +# Finished processing logs sql/sql_logs +# MonetDB/SQL module loaded +# MonetDB/R module loaded + +Ready. +# SQL catalog created, loading sql scripts once +# loading sql script: 09_like.sql +# loading sql script: 10_math.sql +# loading sql script: 11_times.sql +# loading sql script: 12_url.sql +# loading sql script: 13_date.sql +# loading sql script: 14_inet.sql +# loading sql script: 15_querylog.sql +# loading sql script: 16_tracelog.sql +# loading sql script: 17_temporal.sql +# loading sql script: 20_vacuum.sql +# loading sql script: 21_dependency_functions.sql +# loading sql script: 22_clients.sql +# loading sql script: 23_skyserver.sql +# loading sql script: 24_zorder.sql +# loading sql script: 25_debug.sql +# loading sql script: 26_sysmon.sql +# loading sql script: 27_rejects.sql +# loading sql script: 39_analytics.sql +# loading sql script: 39_analytics_hge.sql +# loading sql script: 40_geom.sql +# loading sql script: 40_json.sql +# loading sql script: 40_json_hge.sql +# loading sql script: 41_md5sum.sql +# loading sql script: 45_uuid.sql +# loading sql script: 46_gsl.sql +# loading sql script: 51_sys_schema_extension.sql +# loading sql script: 72_fits.sql +# loading sql script: 75_storagemodel.sql +# loading sql script: 80_statistics.sql +# loading sql script: 80_udf.sql +# loading sql script: 80_udf_hge.sql +# loading sql script: 90_generator.sql +# loading sql script: 90_generator_hge.sql +# loading sql script: 99_system.sql + +# 11:46:09 > +# 11:46:09 > "ruby" "rubytest.rb" "33382" "mTests_clients_ruby" +# 11:46:09 > + +# Running: +........... + + + +11 runs, 11 assertions, 0 failures, 0 errors, 0 skips + +# 11:46:09 > +# 11:46:09 > "Done." +# 11:46:09 > + diff --git a/clients/ruby/adapter/Makefile.ag b/clients/ruby/adapter/Makefile.ag deleted file mode 100644 --- a/clients/ruby/adapter/Makefile.ag +++ /dev/null @@ -1,13 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# Copyright 2008-2015 MonetDB B.V. - -gem_adapter = { - FILES = activerecord-monetdb-adapter-0.1.gemspec - DIR = $(RUBY_DIR) -} - -EXTRA_DIST = activerecord-monetdb-adapter-0.1.gemspec -EXTRA_DIST_DIR = active_record lib diff --git a/clients/ruby/adapter/active_record/connection_adapters/monetdb_adapter.rb b/clients/ruby/adapter/active_record/connection_adapters/monetdb_adapter.rb deleted file mode 100644 --- a/clients/ruby/adapter/active_record/connection_adapters/monetdb_adapter.rb +++ /dev/null @@ -1,541 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# Copyright 2008-2015 MonetDB B.V. - -# MonetDB Active Record adapter -# monetdb_adapter.rb - -# The code is an adaption of the adapter developer by Michalis Polakis (2008), to work on top of the pure ruby MonetDB -# interface - -require 'active_record/connection_adapters/abstract_adapter' -require 'MonetDB' - -module ActiveRecord - class Base - # Establishes a connection to the database that's used by all Active Record objects - def self.monetdb_connection(config) - require_library_or_gem('MonetDB') - - # extract connection parameters - config = config.symbolize_keys - - host = config[:host] || "127.0.0.1" - port = config[:port] || 50000 - username = config[:username] || "monetdb" - password = config[:password] || "monetdb" - - # Use "sql" as default language if none is specified - lang = config[:lang] || "sql" - - # use empty string as database name if none is specified - database = config[:database] || "" - - dbh = MonetDB.new - ConnectionAdapters::MonetDBAdapter.new(dbh, logger, [host, port, username, password, database, lang], config) - end - end _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list