Merge branch 'bzr/golem' of /Users/distler/Sites/code/instiki
This commit is contained in:
commit
b4758d9bfa
BIN
lib/native/i386-mingw32/sqlite3.dll
Normal file
BIN
lib/native/i386-mingw32/sqlite3.dll
Normal file
Binary file not shown.
88
vendor/plugins/sqlite3-ruby/ChangeLog.cvs
vendored
Normal file
88
vendor/plugins/sqlite3-ruby/ChangeLog.cvs
vendored
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
2005-01-05 09:40 minam
|
||||||
|
|
||||||
|
* Rakefile, sqlite3-ruby-win32.gemspec, sqlite3-ruby.gemspec: Added
|
||||||
|
win32 gem.
|
||||||
|
|
||||||
|
2005-01-05 07:31 minam
|
||||||
|
|
||||||
|
* Rakefile, test/tc_integration.rb, test/tests.rb: Added
|
||||||
|
native-vs-dl benchmark to Rakefile. Added SQLITE3_DRIVERS
|
||||||
|
environment variable to integration test to specify which
|
||||||
|
driver(s) should be tested (defaults to "Native").
|
||||||
|
|
||||||
|
2005-01-04 14:26 minam
|
||||||
|
|
||||||
|
* ext/sqlite3_api/sqlite3_api.i, lib/sqlite3/database.rb,
|
||||||
|
lib/sqlite3/driver/native/driver.rb, test/tc_database.rb,
|
||||||
|
test/tc_integration.rb, test/tests.rb: Unit tests: done. Bugs:
|
||||||
|
fixed.
|
||||||
|
|
||||||
|
2005-01-03 23:13 minam
|
||||||
|
|
||||||
|
* ext/sqlite3_api/sqlite3_api.i, lib/sqlite3/database.rb,
|
||||||
|
lib/sqlite3/driver/dl/driver.rb,
|
||||||
|
lib/sqlite3/driver/native/driver.rb, test/tc_integration.rb:
|
||||||
|
Custom functions (aggregate and otherwise) are supported by the
|
||||||
|
native driver now. Test cases for the same.
|
||||||
|
|
||||||
|
2005-01-03 13:51 minam
|
||||||
|
|
||||||
|
* ext/sqlite3_api/MANIFEST, ext/sqlite3_api/extconf.rb,
|
||||||
|
ext/sqlite3_api/post-clean.rb, ext/sqlite3_api/post-distclean.rb,
|
||||||
|
ext/sqlite3_api/sqlite3_api.i, lib/sqlite3/database.rb,
|
||||||
|
lib/sqlite3/resultset.rb, lib/sqlite3/version.rb,
|
||||||
|
lib/sqlite3/driver/dl/driver.rb,
|
||||||
|
lib/sqlite3/driver/native/driver.rb, test/native-vs-dl.rb,
|
||||||
|
test/tc_integration.rb: Added preliminary implementation of
|
||||||
|
native driver (swig-based), and integration tests.
|
||||||
|
|
||||||
|
2004-12-29 19:37 minam
|
||||||
|
|
||||||
|
* lib/sqlite3/driver/dl/driver.rb: Some fixes to allow the DL
|
||||||
|
driver to work with Ruby 1.8.1.
|
||||||
|
|
||||||
|
2004-12-29 14:52 minam
|
||||||
|
|
||||||
|
* lib/sqlite3/: database.rb, version.rb: Made #quote a class method
|
||||||
|
(again). Bumped version to 0.6.
|
||||||
|
|
||||||
|
2004-12-25 22:59 minam
|
||||||
|
|
||||||
|
* lib/sqlite3/driver/dl/api.rb: Added check for darwin in supported
|
||||||
|
platforms (thanks to bitsweat).
|
||||||
|
|
||||||
|
2004-12-22 12:38 minam
|
||||||
|
|
||||||
|
* Rakefile: Rakefile wasn't packaging the README file.
|
||||||
|
|
||||||
|
2004-12-21 22:28 minam
|
||||||
|
|
||||||
|
* Rakefile, sqlite3-ruby.gemspec, test/bm.rb: Packaging now works.
|
||||||
|
Added benchmarks.
|
||||||
|
|
||||||
|
2004-12-21 21:45 minam
|
||||||
|
|
||||||
|
* LICENSE, README, Rakefile, setup.rb, sqlite3-ruby.gemspec,
|
||||||
|
doc/faq/faq.rb, doc/faq/faq.yml, lib/sqlite3.rb,
|
||||||
|
lib/sqlite3/statement.rb, lib/sqlite3/constants.rb,
|
||||||
|
lib/sqlite3/database.rb, lib/sqlite3/resultset.rb,
|
||||||
|
lib/sqlite3/translator.rb, lib/sqlite3/value.rb,
|
||||||
|
lib/sqlite3/version.rb, lib/sqlite3/errors.rb,
|
||||||
|
lib/sqlite3/pragmas.rb, lib/sqlite3/driver/dl/api.rb,
|
||||||
|
lib/sqlite3/driver/dl/driver.rb, test/mocks.rb,
|
||||||
|
test/tc_database.rb, test/tests.rb, test/driver/dl/tc_driver.rb:
|
||||||
|
Initial import
|
||||||
|
|
||||||
|
2004-12-21 21:45 minam
|
||||||
|
|
||||||
|
* LICENSE, README, Rakefile, setup.rb, sqlite3-ruby.gemspec,
|
||||||
|
doc/faq/faq.rb, doc/faq/faq.yml, lib/sqlite3.rb,
|
||||||
|
lib/sqlite3/statement.rb, lib/sqlite3/constants.rb,
|
||||||
|
lib/sqlite3/database.rb, lib/sqlite3/resultset.rb,
|
||||||
|
lib/sqlite3/translator.rb, lib/sqlite3/value.rb,
|
||||||
|
lib/sqlite3/version.rb, lib/sqlite3/errors.rb,
|
||||||
|
lib/sqlite3/pragmas.rb, lib/sqlite3/driver/dl/api.rb,
|
||||||
|
lib/sqlite3/driver/dl/driver.rb, test/mocks.rb,
|
||||||
|
test/tc_database.rb, test/tests.rb, test/driver/dl/tc_driver.rb:
|
||||||
|
Initial revision
|
||||||
|
|
68
vendor/plugins/sqlite3-ruby/History.txt
vendored
Normal file
68
vendor/plugins/sqlite3-ruby/History.txt
vendored
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
=== 1.2.5 / 25 Jul 2009
|
||||||
|
|
||||||
|
* Check for illegal nil before executing SQL [Erik Veenstra]
|
||||||
|
* Switch to Hoe for gem task management and packaging.
|
||||||
|
* Advertise rake-compiler as development dependency.
|
||||||
|
* Build gem binaries for Windows.
|
||||||
|
* Improved Ruby 1.9 support compatibility.
|
||||||
|
* Taint returned values. Patch #20325.
|
||||||
|
|
||||||
|
|
||||||
|
=== 1.2.4.1 (internal) / 5 Jul 2009
|
||||||
|
|
||||||
|
* Check for illegal nil before executing SQL [Erik Veenstra]
|
||||||
|
* Switch to Hoe for gem task management and packaging.
|
||||||
|
* Advertise rake-compiler as development dependency.
|
||||||
|
* Build gem binaries for Windows.
|
||||||
|
* Improved Ruby 1.9 support compatibility.
|
||||||
|
|
||||||
|
|
||||||
|
=== 1.2.4 / 27 Aug 2008
|
||||||
|
|
||||||
|
* Package the updated C file for source builds. [Jamis Buck]
|
||||||
|
|
||||||
|
|
||||||
|
=== 1.2.3 / 26 Aug 2008
|
||||||
|
|
||||||
|
* Fix incorrect permissions on database.rb and translator.rb [Various]
|
||||||
|
|
||||||
|
* Avoid using Object#extend for greater speedups [Erik Veenstra]
|
||||||
|
|
||||||
|
* Ruby 1.9 compatibility tweaks for Array#zip [jimmy88@gmail.com]
|
||||||
|
|
||||||
|
* Fix linking against Ruby 1.8.5 [Rob Holland <rob@inversepath.com>]
|
||||||
|
|
||||||
|
|
||||||
|
=== 1.2.2 / 31 May 2008
|
||||||
|
|
||||||
|
* Make the table_info method adjust the returned default value for the rows
|
||||||
|
so that the sqlite3 change in 3.3.8 and greater can be handled
|
||||||
|
transparently [Jamis Buck <jamis@37signals.com>]
|
||||||
|
|
||||||
|
* Ruby 1.9 compatibility tweaks [Roman Le Negrate <roman2k@free.fr>]
|
||||||
|
|
||||||
|
* Various performance enhancements [thanks Erik Veenstra]
|
||||||
|
|
||||||
|
* Correct busy_handler documentation [Rob Holland <rob@inversepath.com>]
|
||||||
|
|
||||||
|
* Use int_bind64 on Fixnum values larger than a 32bit C int can take. [Rob Holland <rob@inversepath.com>]
|
||||||
|
|
||||||
|
* Work around a quirk in SQLite's error reporting by calling sqlite3_reset
|
||||||
|
to produce a more informative error code upon a failure from
|
||||||
|
sqlite3_step. [Rob Holland <rob@inversepath.com>]
|
||||||
|
|
||||||
|
* Various documentation, test, and style tweaks [Rob Holland <rob@inversepath.com>]
|
||||||
|
|
||||||
|
* Be more granular with time/data translation [Rob Holland <rob@inversepath.com>]
|
||||||
|
|
||||||
|
* Use Date directly for parsing rather than going via Time [Rob Holland <rob@inversepath.com>]
|
||||||
|
|
||||||
|
* Check for the rt library and fdatasync so we link against that when
|
||||||
|
needed [Rob Holland <rob@inversepath.com>]
|
||||||
|
|
||||||
|
* Rename data structures to avoid collision on win32. based on patch
|
||||||
|
by: Luis Lavena [Rob Holland <rob@inversepath.com>]
|
||||||
|
|
||||||
|
* Add test for defaults [Daniel Rodríguez Troitiño]
|
||||||
|
|
||||||
|
* Correctly unquote double-quoted pragma defaults [Łukasz Dargiewicz <lukasz.dargiewicz@gmail.com>]
|
41
vendor/plugins/sqlite3-ruby/Manifest.txt
vendored
Normal file
41
vendor/plugins/sqlite3-ruby/Manifest.txt
vendored
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
ChangeLog.cvs
|
||||||
|
History.txt
|
||||||
|
LICENSE
|
||||||
|
Manifest.txt
|
||||||
|
README.txt
|
||||||
|
Rakefile
|
||||||
|
ext/sqlite3_api/extconf.rb
|
||||||
|
ext/sqlite3_api/sqlite3_api.i
|
||||||
|
ext/sqlite3_api/sqlite3_api_wrap.c
|
||||||
|
faq/faq.rb
|
||||||
|
faq/faq.yml
|
||||||
|
lib/sqlite3.rb
|
||||||
|
lib/sqlite3/constants.rb
|
||||||
|
lib/sqlite3/database.rb
|
||||||
|
lib/sqlite3/driver/dl/api.rb
|
||||||
|
lib/sqlite3/driver/dl/driver.rb
|
||||||
|
lib/sqlite3/driver/native/driver.rb
|
||||||
|
lib/sqlite3/errors.rb
|
||||||
|
lib/sqlite3/pragmas.rb
|
||||||
|
lib/sqlite3/resultset.rb
|
||||||
|
lib/sqlite3/statement.rb
|
||||||
|
lib/sqlite3/translator.rb
|
||||||
|
lib/sqlite3/value.rb
|
||||||
|
lib/sqlite3/version.rb
|
||||||
|
setup.rb
|
||||||
|
tasks/benchmark.rake
|
||||||
|
tasks/faq.rake
|
||||||
|
tasks/gem.rake
|
||||||
|
tasks/native.rake
|
||||||
|
tasks/vendor_sqlite3.rake
|
||||||
|
test/bm.rb
|
||||||
|
test/driver/dl/tc_driver.rb
|
||||||
|
test/helper.rb
|
||||||
|
test/native-vs-dl.rb
|
||||||
|
test/test_database.rb
|
||||||
|
test/test_errors.rb
|
||||||
|
test/test_integration.rb
|
||||||
|
test/test_integration_open_close.rb
|
||||||
|
test/test_integration_pending.rb
|
||||||
|
test/test_integration_resultset.rb
|
||||||
|
test/test_integration_statement.rb
|
56
vendor/plugins/sqlite3-ruby/README.txt
vendored
Normal file
56
vendor/plugins/sqlite3-ruby/README.txt
vendored
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
= SQLite3/Ruby Interface
|
||||||
|
|
||||||
|
* http://sqlite3-ruby.rubyforge.org
|
||||||
|
* http://rubyforge.org/projects/sqlite3-ruby
|
||||||
|
* http://github.com/jamis/sqlite3-ruby
|
||||||
|
|
||||||
|
== DESCRIPTION
|
||||||
|
|
||||||
|
This module allows Ruby programs to interface with the SQLite3
|
||||||
|
database engine (http://www.sqlite.org). You must have the
|
||||||
|
SQLite engine installed in order to build this module.
|
||||||
|
|
||||||
|
Note that this module is NOT compatible with SQLite 2.x.
|
||||||
|
|
||||||
|
== Compilation and Installation
|
||||||
|
|
||||||
|
Simply do the following, after installing SQLite3:
|
||||||
|
|
||||||
|
ruby setup.rb config
|
||||||
|
ruby setup.rb setup
|
||||||
|
ruby setup.rb install
|
||||||
|
|
||||||
|
Alternatively, you can download and install the RubyGem package for
|
||||||
|
SQLite3/Ruby (you must have RubyGems and SQLite3 installed, first):
|
||||||
|
|
||||||
|
gem install sqlite3-ruby
|
||||||
|
|
||||||
|
If you have sqlite3 installed in a non-standard location, you can specify the location of the include and lib files by doing:
|
||||||
|
|
||||||
|
gem install sqlite3-ruby -- --with-sqlite3-include=/opt/local/include \
|
||||||
|
--with-sqlite3-lib=/opt/local/lib
|
||||||
|
|
||||||
|
Also, the gem ships with the C source-code pre-built, so (as of version 1.1.1)
|
||||||
|
you no longer need to have SWIG installed. However, if you have SWIG installed
|
||||||
|
and you want to generate the C file yourself, you can specify the
|
||||||
|
<code>--with-swig</code> option.
|
||||||
|
|
||||||
|
== Usage
|
||||||
|
|
||||||
|
For help figuring out the SQLite3/Ruby interface, check out the
|
||||||
|
FAQ[http://sqlite-ruby.rubyforge.org/sqlite3/faq.html]. It includes examples of
|
||||||
|
usage. If you have any questions that you feel should be address in the
|
||||||
|
FAQ, please send them to jamis@37signals.com
|
||||||
|
|
||||||
|
== Source Code
|
||||||
|
|
||||||
|
The source repository is accessible via git:
|
||||||
|
|
||||||
|
git clone git://github.com/jamis/sqlite3-ruby.git
|
||||||
|
|
||||||
|
== Contact Information
|
||||||
|
|
||||||
|
The project page is http://rubyforge.org/projects/sqlite-ruby. There, you can
|
||||||
|
find links to mailing lists and forums that you can use to discuss this
|
||||||
|
library. Additionally, there are trackers for submitting bugs and feature
|
||||||
|
requests. Feel free to use them!
|
191
vendor/plugins/sqlite3-ruby/Rakefile
vendored
191
vendor/plugins/sqlite3-ruby/Rakefile
vendored
|
@ -1,192 +1,5 @@
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
require 'rake'
|
require 'rake'
|
||||||
require 'rake/testtask'
|
|
||||||
require 'rake/rdoctask'
|
|
||||||
require 'rake/contrib/sshpublisher'
|
|
||||||
|
|
||||||
require "./lib/sqlite3/version"
|
# load rakefile extensions (tasks)
|
||||||
|
Dir['tasks/*.rake'].each { |f| import f }
|
||||||
PACKAGE_NAME = "sqlite3-ruby"
|
|
||||||
PACKAGE_VERSION = SQLite3::Version::STRING
|
|
||||||
|
|
||||||
puts "name : #{PACKAGE_NAME}"
|
|
||||||
puts "version: #{PACKAGE_VERSION}"
|
|
||||||
|
|
||||||
SOURCE_FILES = FileList.new do |fl|
|
|
||||||
[ "ext", "lib", "test" ].each do |dir|
|
|
||||||
fl.include "#{dir}/**/*"
|
|
||||||
end
|
|
||||||
fl.include "Rakefile"
|
|
||||||
end
|
|
||||||
|
|
||||||
PACKAGE_FILES = FileList.new do |fl|
|
|
||||||
[ "api", "doc" ].each do |dir|
|
|
||||||
fl.include "#{dir}/**/*"
|
|
||||||
end
|
|
||||||
fl.include "CHANGELOG.rdoc", "README.rdoc", "LICENSE", "#{PACKAGE_NAME}.gemspec", "setup.rb"
|
|
||||||
fl.include SOURCE_FILES
|
|
||||||
end
|
|
||||||
|
|
||||||
Gem.manage_gems
|
|
||||||
|
|
||||||
def can_require( file )
|
|
||||||
begin
|
|
||||||
require file
|
|
||||||
return true
|
|
||||||
rescue LoadError
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Default task"
|
|
||||||
task :default => [ :test ]
|
|
||||||
|
|
||||||
desc "Clean generated files"
|
|
||||||
task :clean do
|
|
||||||
rm_rf "ChangeLog"
|
|
||||||
rm_rf "pkg"
|
|
||||||
rm_rf "api"
|
|
||||||
rm_f "doc/faq/faq.html"
|
|
||||||
|
|
||||||
native_files = [ "Makefile", "mkmf.log", "sqlite3_api.so",
|
|
||||||
"sqlite3_api.bundle", "sqlite3_api_wrap.o" ]
|
|
||||||
native_files.each { |f| rm_f "ext/sqlite3_api/#{f}" }
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Run benchmarks vs. sqlite-ruby"
|
|
||||||
task :benchmark do
|
|
||||||
ruby "test/bm.rb"
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Run benchmarks dl vs. native"
|
|
||||||
task :benchmark2 do
|
|
||||||
ruby "test/native-vs-dl.rb"
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Generate the FAQ document"
|
|
||||||
task :faq => "doc/faq/faq.html"
|
|
||||||
|
|
||||||
file "doc/faq/faq.html" => [ "doc/faq/faq.rb", "doc/faq/faq.yml" ] do
|
|
||||||
cd( "doc/faq" ) { ruby "faq.rb > faq.html" }
|
|
||||||
end
|
|
||||||
|
|
||||||
Rake::TestTask.new do |t|
|
|
||||||
t.test_files = [ "test/tests.rb" ]
|
|
||||||
t.verbose = true
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Build all packages"
|
|
||||||
task :package
|
|
||||||
|
|
||||||
package_name = "#{PACKAGE_NAME}-#{PACKAGE_VERSION}"
|
|
||||||
package_dir = "pkg"
|
|
||||||
package_dir_path = "#{package_dir}/#{package_name}"
|
|
||||||
|
|
||||||
gz_file = "#{package_name}.tar.gz"
|
|
||||||
bz2_file = "#{package_name}.tar.bz2"
|
|
||||||
zip_file = "#{package_name}.zip"
|
|
||||||
gem_file = "#{package_name}.gem"
|
|
||||||
|
|
||||||
task :gzip => SOURCE_FILES + [ :faq, :rdoc, "#{package_dir}/#{gz_file}" ]
|
|
||||||
task :bzip => SOURCE_FILES + [ :faq, :rdoc, "#{package_dir}/#{bz2_file}" ]
|
|
||||||
task :zip => SOURCE_FILES + [ :faq, :rdoc, "#{package_dir}/#{zip_file}" ]
|
|
||||||
task :gem => SOURCE_FILES + [ :faq, "#{package_dir}/#{gem_file}" ]
|
|
||||||
|
|
||||||
task :package => [ :gzip, :bzip, :zip, :gem ]
|
|
||||||
|
|
||||||
directory package_dir
|
|
||||||
|
|
||||||
file package_dir_path do
|
|
||||||
mkdir_p package_dir_path rescue nil
|
|
||||||
PACKAGE_FILES.each do |fn|
|
|
||||||
f = File.join( package_dir_path, fn )
|
|
||||||
if File.directory?( fn )
|
|
||||||
mkdir_p f unless File.exist?( f )
|
|
||||||
else
|
|
||||||
dir = File.dirname( f )
|
|
||||||
mkdir_p dir unless File.exist?( dir )
|
|
||||||
rm_f f
|
|
||||||
safe_ln fn, f
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
file "#{package_dir}/#{zip_file}" => package_dir_path do
|
|
||||||
rm_f "#{package_dir}/#{zip_file}"
|
|
||||||
chdir package_dir do
|
|
||||||
sh %{zip -r #{zip_file} #{package_name}}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
file "#{package_dir}/#{gz_file}" => package_dir_path do
|
|
||||||
rm_f "#{package_dir}/#{gz_file}"
|
|
||||||
chdir package_dir do
|
|
||||||
sh %{tar czvf #{gz_file} #{package_name}}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
file "#{package_dir}/#{bz2_file}" => package_dir_path do
|
|
||||||
rm_f "#{package_dir}/#{bz2_file}"
|
|
||||||
chdir package_dir do
|
|
||||||
sh %{tar cjvf #{bz2_file} #{package_name}}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
file "#{package_dir}/#{gem_file}" => package_dir do
|
|
||||||
spec = eval(File.read(PACKAGE_NAME+".gemspec"))
|
|
||||||
Gem::Builder.new(spec).build
|
|
||||||
mv gem_file, "#{package_dir}/#{gem_file}"
|
|
||||||
end
|
|
||||||
|
|
||||||
Rake::RDocTask.new do |rdoc|
|
|
||||||
rdoc.rdoc_dir = 'api'
|
|
||||||
rdoc.title = "SQLite3/Ruby"
|
|
||||||
rdoc.options += %w(--line-numbers --inline-source --main README.rdoc)
|
|
||||||
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
||||||
|
|
||||||
if can_require( "rdoc/generators/template/html/jamis" )
|
|
||||||
rdoc.template = "jamis"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Publish the API documentation"
|
|
||||||
task :pubrdoc => [ :rdoc ] do
|
|
||||||
Rake::SshDirPublisher.new(
|
|
||||||
"minam@rubyforge.org",
|
|
||||||
"/var/www/gforge-projects/sqlite-ruby/sqlite3/",
|
|
||||||
"api" ).upload
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Publish the FAQ"
|
|
||||||
task :pubfaq => [ :faq ] do
|
|
||||||
Rake::SshFilePublisher.new(
|
|
||||||
"minam@rubyforge.org",
|
|
||||||
"/var/www/gforge-projects/sqlite-ruby/sqlite3",
|
|
||||||
"doc/faq",
|
|
||||||
"faq.html" ).upload
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Publish the documentation"
|
|
||||||
task :pubdoc => [:pubrdoc, :pubfaq]
|
|
||||||
|
|
||||||
desc "Build the Native extension"
|
|
||||||
task :build do
|
|
||||||
cd 'ext/sqlite3_api' do
|
|
||||||
ruby 'extconf.rb'
|
|
||||||
system 'make'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Package a beta release"
|
|
||||||
task :beta do
|
|
||||||
require 'yaml'
|
|
||||||
system 'svn up'
|
|
||||||
rev = YAML.load(`svn info`)["Revision"]
|
|
||||||
version = File.read("lib/sqlite3/version.rb")
|
|
||||||
version.gsub!(/#:beta-tag:/, %(STRING << ".#{rev}"))
|
|
||||||
File.open("lib/sqlite3/version.rb", "w") { |f| f.write(version) }
|
|
||||||
|
|
||||||
system "rake gem"
|
|
||||||
|
|
||||||
system "svn revert lib/sqlite3/version.rb"
|
|
||||||
end
|
|
||||||
|
|
|
@ -1,16 +1,10 @@
|
||||||
require 'mkmf'
|
require 'mkmf'
|
||||||
|
|
||||||
SWIG_WRAP = "sqlite3_api_wrap.c"
|
dir_config( "sqlite3" )
|
||||||
|
|
||||||
dir_config( "sqlite3", "/usr/local" )
|
|
||||||
|
|
||||||
have_library( "rt", "fdatasync" )
|
have_library( "rt", "fdatasync" )
|
||||||
|
|
||||||
if have_header( "sqlite3.h" ) && have_library( "sqlite3", "sqlite3_open" )
|
if have_header( "sqlite3.h" ) && have_library( "sqlite3", "sqlite3_open" ) then
|
||||||
if !File.exists?( SWIG_WRAP ) || with_config( "swig", false )
|
$CFLAGS << " -fno-strict-aliasing" unless RUBY_PLATFORM =~ /mswin/
|
||||||
puts "creating #{SWIG_WRAP}"
|
|
||||||
system "swig -ruby sqlite3_api.i" or raise "could not build wrapper via swig (perhaps swig is not installed?)"
|
|
||||||
end
|
|
||||||
|
|
||||||
create_makefile( "sqlite3_api" )
|
create_makefile( "sqlite3_api" )
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,6 +12,10 @@
|
||||||
#define RSTRING_LEN(s) (RSTRING(s)->len)
|
#define RSTRING_LEN(s) (RSTRING(s)->len)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef STR2CSTR
|
||||||
|
#define STR2CSTR StringValueCStr
|
||||||
|
#endif
|
||||||
|
|
||||||
#define Init_API Init_sqlite3_api
|
#define Init_API Init_sqlite3_api
|
||||||
|
|
||||||
struct CallbackData {
|
struct CallbackData {
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -12,13 +12,11 @@ module SQLite3
|
||||||
#
|
#
|
||||||
# require 'sqlite3'
|
# require 'sqlite3'
|
||||||
#
|
#
|
||||||
# db = SQLite3::Database.new( "data.db" )
|
# SQLite3::Database.new( "data.db" ) do |db|
|
||||||
#
|
|
||||||
# db.execute( "select * from table" ) do |row|
|
# db.execute( "select * from table" ) do |row|
|
||||||
# p row
|
# p row
|
||||||
# end
|
# end
|
||||||
#
|
# end
|
||||||
# db.close
|
|
||||||
#
|
#
|
||||||
# It wraps the lower-level methods provides by the selected driver, and
|
# It wraps the lower-level methods provides by the selected driver, and
|
||||||
# includes the Pragmas module for access to various pragma convenience
|
# includes the Pragmas module for access to various pragma convenience
|
||||||
|
@ -69,7 +67,7 @@ module SQLite3
|
||||||
#
|
#
|
||||||
# By default, the new database will return result rows as arrays
|
# By default, the new database will return result rows as arrays
|
||||||
# (#results_as_hash) and has type translation disabled (#type_translation=).
|
# (#results_as_hash) and has type translation disabled (#type_translation=).
|
||||||
def initialize( file_name, options={} )
|
def initialize( file_name, options={} ) # :yields: db
|
||||||
utf16 = options.fetch(:utf16, false)
|
utf16 = options.fetch(:utf16, false)
|
||||||
load_driver( options[:driver] )
|
load_driver( options[:driver] )
|
||||||
|
|
||||||
|
@ -83,6 +81,14 @@ module SQLite3
|
||||||
@type_translation = options.fetch(:type_translation,false)
|
@type_translation = options.fetch(:type_translation,false)
|
||||||
@translator = nil
|
@translator = nil
|
||||||
@transaction_active = false
|
@transaction_active = false
|
||||||
|
|
||||||
|
if block_given?
|
||||||
|
begin
|
||||||
|
yield self
|
||||||
|
ensure
|
||||||
|
self.close
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return +true+ if the string is a valid (ie, parsable) SQL statement, and
|
# Return +true+ if the string is a valid (ie, parsable) SQL statement, and
|
||||||
|
|
|
@ -10,7 +10,7 @@ module SQLite3 ; module Driver; module DL;
|
||||||
"libsqlite3.dylib"
|
"libsqlite3.dylib"
|
||||||
when /linux/, /freebsd|netbsd|openbsd|dragonfly/, /solaris/
|
when /linux/, /freebsd|netbsd|openbsd|dragonfly/, /solaris/
|
||||||
"libsqlite3.so"
|
"libsqlite3.so"
|
||||||
when /win32/
|
when /mswin|mingw/
|
||||||
"sqlite3.dll"
|
"sqlite3.dll"
|
||||||
else
|
else
|
||||||
abort <<-EOF
|
abort <<-EOF
|
||||||
|
|
|
@ -1,4 +1,12 @@
|
||||||
require 'sqlite3_api'
|
# support multiple ruby version (fat binaries under windows)
|
||||||
|
begin
|
||||||
|
require 'sqlite3_api'
|
||||||
|
rescue LoadError
|
||||||
|
if RUBY_PLATFORM =~ /mingw|mswin/ then
|
||||||
|
RUBY_VERSION =~ /(\d+.\d+)/
|
||||||
|
require "#{$1}/sqlite3_api"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
module SQLite3 ; module Driver ; module Native
|
module SQLite3 ; module Driver ; module Native
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,10 @@ module SQLite3
|
||||||
|
|
||||||
if @db.results_as_hash
|
if @db.results_as_hash
|
||||||
new_row = HashWithTypes[ *( @stmt.columns.zip( row ).to_a.flatten ) ]
|
new_row = HashWithTypes[ *( @stmt.columns.zip( row ).to_a.flatten ) ]
|
||||||
row.each_with_index { |value,idx| new_row[idx] = value }
|
row.each_with_index { |value,idx|
|
||||||
|
value.taint
|
||||||
|
new_row[idx] = value
|
||||||
|
}
|
||||||
row = new_row
|
row = new_row
|
||||||
else
|
else
|
||||||
if row.respond_to?(:fields)
|
if row.respond_to?(:fields)
|
||||||
|
@ -131,6 +134,7 @@ module SQLite3
|
||||||
row = ArrayWithTypesAndFields.new(row)
|
row = ArrayWithTypesAndFields.new(row)
|
||||||
end
|
end
|
||||||
row.fields = @stmt.columns
|
row.fields = @stmt.columns
|
||||||
|
row.each { |column| column.taint }
|
||||||
end
|
end
|
||||||
|
|
||||||
row.types = @stmt.types
|
row.types = @stmt.types
|
||||||
|
|
|
@ -31,6 +31,7 @@ module SQLite3
|
||||||
# statement (i.e., separated by semicolons), then the #remainder property
|
# statement (i.e., separated by semicolons), then the #remainder property
|
||||||
# will be set to the trailing text.
|
# will be set to the trailing text.
|
||||||
def initialize( db, sql, utf16=false )
|
def initialize( db, sql, utf16=false )
|
||||||
|
raise ArgumentError, "nil argument passed as sql text" unless sql
|
||||||
@db = db
|
@db = db
|
||||||
@driver = @db.driver
|
@driver = @db.driver
|
||||||
@closed = false
|
@closed = false
|
||||||
|
@ -193,8 +194,8 @@ module SQLite3
|
||||||
# that this may execute the statement in order to obtain the metadata; this
|
# that this may execute the statement in order to obtain the metadata; this
|
||||||
# makes it a (potentially) expensive operation.
|
# makes it a (potentially) expensive operation.
|
||||||
def types
|
def types
|
||||||
get_metadata unless @types
|
get_metadata unless defined?(@types)
|
||||||
return @types
|
@types
|
||||||
end
|
end
|
||||||
|
|
||||||
# A convenience method for obtaining the metadata about the query. Note
|
# A convenience method for obtaining the metadata about the query. Note
|
||||||
|
|
|
@ -4,11 +4,13 @@ module SQLite3
|
||||||
|
|
||||||
MAJOR = 1
|
MAJOR = 1
|
||||||
MINOR = 2
|
MINOR = 2
|
||||||
TINY = 4
|
TINY = 5
|
||||||
|
BUILD = nil
|
||||||
|
|
||||||
STRING = [ MAJOR, MINOR, TINY ].join( "." )
|
STRING = [ MAJOR, MINOR, TINY, BUILD ].compact.join( "." )
|
||||||
#:beta-tag:
|
#:beta-tag:
|
||||||
|
|
||||||
|
VERSION = '1.2.5'
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
141
vendor/plugins/sqlite3-ruby/sqlite3-ruby.gemspec
vendored
Normal file
141
vendor/plugins/sqlite3-ruby/sqlite3-ruby.gemspec
vendored
Normal file
|
@ -0,0 +1,141 @@
|
||||||
|
--- !ruby/object:Gem::Specification
|
||||||
|
name: sqlite3-ruby
|
||||||
|
version: !ruby/object:Gem::Version
|
||||||
|
version: 1.2.5
|
||||||
|
platform: ruby
|
||||||
|
authors:
|
||||||
|
- Jamis Buck
|
||||||
|
autorequire:
|
||||||
|
bindir: bin
|
||||||
|
cert_chain: []
|
||||||
|
|
||||||
|
date: 2009-07-25 00:00:00 -03:00
|
||||||
|
default_executable:
|
||||||
|
dependencies:
|
||||||
|
- !ruby/object:Gem::Dependency
|
||||||
|
name: mocha
|
||||||
|
type: :development
|
||||||
|
version_requirement:
|
||||||
|
version_requirements: !ruby/object:Gem::Requirement
|
||||||
|
requirements:
|
||||||
|
- - ">="
|
||||||
|
- !ruby/object:Gem::Version
|
||||||
|
version: "0"
|
||||||
|
version:
|
||||||
|
- !ruby/object:Gem::Dependency
|
||||||
|
name: rake-compiler
|
||||||
|
type: :development
|
||||||
|
version_requirement:
|
||||||
|
version_requirements: !ruby/object:Gem::Requirement
|
||||||
|
requirements:
|
||||||
|
- - ~>
|
||||||
|
- !ruby/object:Gem::Version
|
||||||
|
version: 0.5.0
|
||||||
|
version:
|
||||||
|
- !ruby/object:Gem::Dependency
|
||||||
|
name: hoe
|
||||||
|
type: :development
|
||||||
|
version_requirement:
|
||||||
|
version_requirements: !ruby/object:Gem::Requirement
|
||||||
|
requirements:
|
||||||
|
- - ">="
|
||||||
|
- !ruby/object:Gem::Version
|
||||||
|
version: 2.3.2
|
||||||
|
version:
|
||||||
|
description: |-
|
||||||
|
This module allows Ruby programs to interface with the SQLite3
|
||||||
|
database engine (http://www.sqlite.org). You must have the
|
||||||
|
SQLite engine installed in order to build this module.
|
||||||
|
|
||||||
|
Note that this module is NOT compatible with SQLite 2.x.
|
||||||
|
email:
|
||||||
|
- jamis@37signals.com
|
||||||
|
executables: []
|
||||||
|
|
||||||
|
extensions:
|
||||||
|
- ext/sqlite3_api/extconf.rb
|
||||||
|
extra_rdoc_files:
|
||||||
|
- History.txt
|
||||||
|
- Manifest.txt
|
||||||
|
- README.txt
|
||||||
|
files:
|
||||||
|
- ChangeLog.cvs
|
||||||
|
- History.txt
|
||||||
|
- LICENSE
|
||||||
|
- Manifest.txt
|
||||||
|
- README.txt
|
||||||
|
- Rakefile
|
||||||
|
- ext/sqlite3_api/extconf.rb
|
||||||
|
- ext/sqlite3_api/sqlite3_api.i
|
||||||
|
- ext/sqlite3_api/sqlite3_api_wrap.c
|
||||||
|
- faq/faq.rb
|
||||||
|
- faq/faq.yml
|
||||||
|
- lib/sqlite3.rb
|
||||||
|
- lib/sqlite3/constants.rb
|
||||||
|
- lib/sqlite3/database.rb
|
||||||
|
- lib/sqlite3/driver/dl/api.rb
|
||||||
|
- lib/sqlite3/driver/dl/driver.rb
|
||||||
|
- lib/sqlite3/driver/native/driver.rb
|
||||||
|
- lib/sqlite3/errors.rb
|
||||||
|
- lib/sqlite3/pragmas.rb
|
||||||
|
- lib/sqlite3/resultset.rb
|
||||||
|
- lib/sqlite3/statement.rb
|
||||||
|
- lib/sqlite3/translator.rb
|
||||||
|
- lib/sqlite3/value.rb
|
||||||
|
- lib/sqlite3/version.rb
|
||||||
|
- setup.rb
|
||||||
|
- tasks/benchmark.rake
|
||||||
|
- tasks/faq.rake
|
||||||
|
- tasks/gem.rake
|
||||||
|
- tasks/native.rake
|
||||||
|
- tasks/vendor_sqlite3.rake
|
||||||
|
- test/bm.rb
|
||||||
|
- test/driver/dl/tc_driver.rb
|
||||||
|
- test/helper.rb
|
||||||
|
- test/native-vs-dl.rb
|
||||||
|
- test/test_database.rb
|
||||||
|
- test/test_errors.rb
|
||||||
|
- test/test_integration.rb
|
||||||
|
- test/test_integration_open_close.rb
|
||||||
|
- test/test_integration_pending.rb
|
||||||
|
- test/test_integration_resultset.rb
|
||||||
|
- test/test_integration_statement.rb
|
||||||
|
has_rdoc: true
|
||||||
|
homepage: http://sqlite3-ruby.rubyforge.org
|
||||||
|
licenses: []
|
||||||
|
|
||||||
|
post_install_message:
|
||||||
|
rdoc_options:
|
||||||
|
- --main
|
||||||
|
- README.txt
|
||||||
|
- --main=README.txt
|
||||||
|
require_paths:
|
||||||
|
- lib
|
||||||
|
- ext
|
||||||
|
required_ruby_version: !ruby/object:Gem::Requirement
|
||||||
|
requirements:
|
||||||
|
- - ">"
|
||||||
|
- !ruby/object:Gem::Version
|
||||||
|
version: 1.8.5
|
||||||
|
version:
|
||||||
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
||||||
|
requirements:
|
||||||
|
- - ">="
|
||||||
|
- !ruby/object:Gem::Version
|
||||||
|
version: "0"
|
||||||
|
version:
|
||||||
|
requirements: []
|
||||||
|
|
||||||
|
rubyforge_project: sqlite-ruby
|
||||||
|
rubygems_version: 1.3.5
|
||||||
|
signing_key:
|
||||||
|
specification_version: 3
|
||||||
|
summary: This module allows Ruby programs to interface with the SQLite3 database engine (http://www.sqlite.org)
|
||||||
|
test_files:
|
||||||
|
- test/test_database.rb
|
||||||
|
- test/test_errors.rb
|
||||||
|
- test/test_integration.rb
|
||||||
|
- test/test_integration_open_close.rb
|
||||||
|
- test/test_integration_pending.rb
|
||||||
|
- test/test_integration_resultset.rb
|
||||||
|
- test/test_integration_statement.rb
|
|
@ -1,6 +1,12 @@
|
||||||
require 'rubygems'
|
# add lib folder to the path
|
||||||
gem 'mocha'
|
$:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
||||||
|
|
||||||
|
require 'sqlite3'
|
||||||
|
|
||||||
|
require 'rubygems'
|
||||||
|
require 'test/unit'
|
||||||
|
|
||||||
|
# define mocks to be used
|
||||||
require 'mocha'
|
require 'mocha'
|
||||||
|
|
||||||
class Driver < Mocha::Mock
|
class Driver < Mocha::Mock
|
||||||
|
@ -43,3 +49,19 @@ class Statement < Mocha::Mock
|
||||||
stubs( :execute ).returns(MockResultSet.new)
|
stubs( :execute ).returns(MockResultSet.new)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# UTF conversion extensions
|
||||||
|
class String
|
||||||
|
def to_utf16(terminate=false)
|
||||||
|
self.split(//).map { |c| c[0] }.pack("v*") +
|
||||||
|
(terminate ? "\0\0" : "")
|
||||||
|
end
|
||||||
|
|
||||||
|
def from_utf16
|
||||||
|
result = ""
|
||||||
|
length.times do |i|
|
||||||
|
result << self[i,1] if i % 2 == 0 && self[i] != 0
|
||||||
|
end
|
||||||
|
result
|
||||||
|
end
|
||||||
|
end
|
1044
vendor/plugins/sqlite3-ruby/test/tc_integration.rb
vendored
1044
vendor/plugins/sqlite3-ruby/test/tc_integration.rb
vendored
File diff suppressed because it is too large
Load diff
|
@ -1,9 +1,4 @@
|
||||||
$:.unshift "../lib"
|
require File.join(File.dirname(__FILE__), 'helper')
|
||||||
|
|
||||||
require 'sqlite3/database'
|
|
||||||
require 'test/unit'
|
|
||||||
|
|
||||||
require 'mocks'
|
|
||||||
|
|
||||||
class TC_Database_Init < Test::Unit::TestCase
|
class TC_Database_Init < Test::Unit::TestCase
|
||||||
def test_new
|
def test_new
|
||||||
|
@ -17,6 +12,18 @@ class TC_Database_Init < Test::Unit::TestCase
|
||||||
assert !db.type_translation
|
assert !db.type_translation
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_new_with_block
|
||||||
|
driver = Driver.new
|
||||||
|
driver.expects(:open).once.with('foo.db', false).returns([0, 'cookie'])
|
||||||
|
Driver.stubs(:new).returns(driver)
|
||||||
|
returned_db = SQLite3::Database.new( "foo.db", :driver => Driver ) do |db|
|
||||||
|
assert !db.closed?
|
||||||
|
assert !db.results_as_hash
|
||||||
|
assert !db.type_translation
|
||||||
|
end
|
||||||
|
assert returned_db.closed?
|
||||||
|
end
|
||||||
|
|
||||||
def test_open
|
def test_open
|
||||||
driver = Driver.new
|
driver = Driver.new
|
||||||
driver.expects(:open).once.with('foo.db', false).returns([0, 'cookie'])
|
driver.expects(:open).once.with('foo.db', false).returns([0, 'cookie'])
|
||||||
|
@ -27,6 +34,18 @@ class TC_Database_Init < Test::Unit::TestCase
|
||||||
assert !db.type_translation
|
assert !db.type_translation
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_open_with_block
|
||||||
|
driver = Driver.new
|
||||||
|
driver.expects(:open).once.with('foo.db', false).returns([0, 'cookie'])
|
||||||
|
Driver.stubs(:new).returns(driver)
|
||||||
|
returned_db = SQLite3::Database.open( "foo.db", :driver => Driver ) do |db|
|
||||||
|
assert !db.closed?
|
||||||
|
assert !db.results_as_hash
|
||||||
|
assert !db.type_translation
|
||||||
|
end
|
||||||
|
assert returned_db.closed?
|
||||||
|
end
|
||||||
|
|
||||||
def test_with_type_translation
|
def test_with_type_translation
|
||||||
db = SQLite3::Database.open( "foo.db", :driver => Driver,
|
db = SQLite3::Database.open( "foo.db", :driver => Driver,
|
||||||
:type_translation => true )
|
:type_translation => true )
|
|
@ -1,8 +1,4 @@
|
||||||
$:.unshift "../lib"
|
require File.join(File.dirname(__FILE__), 'helper')
|
||||||
|
|
||||||
require 'sqlite3/errors'
|
|
||||||
require 'test/unit'
|
|
||||||
require 'mocha'
|
|
||||||
|
|
||||||
class TC_Errors < Test::Unit::TestCase
|
class TC_Errors < Test::Unit::TestCase
|
||||||
(1..26).each do |code|
|
(1..26).each do |code|
|
542
vendor/plugins/sqlite3-ruby/test/test_integration.rb
vendored
Normal file
542
vendor/plugins/sqlite3-ruby/test/test_integration.rb
vendored
Normal file
|
@ -0,0 +1,542 @@
|
||||||
|
require File.join(File.dirname(__FILE__), 'helper')
|
||||||
|
|
||||||
|
class TC_Database_Integration < Test::Unit::TestCase
|
||||||
|
def setup
|
||||||
|
@db = SQLite3::Database.new( "test.db" )
|
||||||
|
@db.transaction do
|
||||||
|
@db.execute "create table foo ( a integer primary key, b text )"
|
||||||
|
@db.execute "insert into foo ( b ) values ( 'foo' )"
|
||||||
|
@db.execute "insert into foo ( b ) values ( 'bar' )"
|
||||||
|
@db.execute "insert into foo ( b ) values ( 'baz' )"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def teardown
|
||||||
|
@db.close
|
||||||
|
File.delete( "test.db" )
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_table_info_with_type_translation_active
|
||||||
|
@db.type_translation = true
|
||||||
|
assert_nothing_raised { @db.table_info("foo") }
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_table_info_with_defaults_for_version_3_3_8_and_higher
|
||||||
|
@db.transaction do
|
||||||
|
@db.execute "create table defaults_test ( a string default NULL, b string default 'Hello' )"
|
||||||
|
data = @db.table_info( "defaults_test" )
|
||||||
|
assert_equal({"name" => "a", "type" => "string", "dflt_value" => nil, "notnull" => "0", "cid" => "0", "pk" => "0"},
|
||||||
|
data[0])
|
||||||
|
assert_equal({"name" => "b", "type" => "string", "dflt_value" => "Hello", "notnull" => "0", "cid" => "1", "pk" => "0"},
|
||||||
|
data[1])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_table_info_without_defaults_for_version_3_3_8_and_higher
|
||||||
|
@db.transaction do
|
||||||
|
@db.execute "create table no_defaults_test ( a integer default 1, b integer )"
|
||||||
|
data = @db.table_info( "no_defaults_test" )
|
||||||
|
assert_equal({"name" => "a", "type" => "integer", "dflt_value" => "1", "notnull" => "0", "cid" => "0", "pk" => "0"},
|
||||||
|
data[0])
|
||||||
|
assert_equal({"name" => "b", "type" => "integer", "dflt_value" => nil, "notnull" => "0", "cid" => "1", "pk" => "0"},
|
||||||
|
data[1])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_complete_fail
|
||||||
|
assert !@db.complete?( "select * from foo" )
|
||||||
|
end
|
||||||
|
def test_complete_success
|
||||||
|
assert @db.complete?( "select * from foo;" )
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_complete_fail_utf16
|
||||||
|
assert !@db.complete?( "select * from foo".to_utf16(false), true )
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_complete_success_utf16
|
||||||
|
assert @db.complete?( "select * from foo;".to_utf16(true), true )
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_errmsg
|
||||||
|
assert_equal "not an error", @db.errmsg
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_errmsg_utf16
|
||||||
|
assert_equal "not an error".to_utf16, @db.errmsg(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_errcode
|
||||||
|
assert_equal 0, @db.errcode
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_trace
|
||||||
|
result = nil
|
||||||
|
@db.trace( "data" ) { |data,sql| result = [ data, sql ]; 0 }
|
||||||
|
@db.execute "select * from foo"
|
||||||
|
assert_equal ["data","select * from foo"], result
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_authorizer_okay
|
||||||
|
@db.authorizer( "data" ) { |data,type,a,b,c,d| 0 }
|
||||||
|
rows = @db.execute "select * from foo"
|
||||||
|
assert_equal 3, rows.length
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_authorizer_error
|
||||||
|
@db.authorizer( "data" ) { |data,type,a,b,c,d| 1 }
|
||||||
|
assert_raise( SQLite3::AuthorizationException ) do
|
||||||
|
@db.execute "select * from foo"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_authorizer_silent
|
||||||
|
@db.authorizer( "data" ) { |data,type,a,b,c,d| 2 }
|
||||||
|
rows = @db.execute "select * from foo"
|
||||||
|
assert rows.empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_prepare_invalid_syntax
|
||||||
|
assert_raise( SQLite3::SQLException ) do
|
||||||
|
@db.prepare "select from foo"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_prepare_invalid_column
|
||||||
|
assert_raise( SQLite3::SQLException ) do
|
||||||
|
@db.prepare "select k from foo"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_prepare_invalid_table
|
||||||
|
assert_raise( SQLite3::SQLException ) do
|
||||||
|
@db.prepare "select * from barf"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_prepare_no_block
|
||||||
|
stmt = @db.prepare "select * from foo"
|
||||||
|
assert stmt.respond_to?(:execute)
|
||||||
|
stmt.close
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_prepare_with_block
|
||||||
|
called = false
|
||||||
|
@db.prepare "select * from foo" do |stmt|
|
||||||
|
called = true
|
||||||
|
assert stmt.respond_to?(:execute)
|
||||||
|
end
|
||||||
|
assert called
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute_no_block_no_bind_no_match
|
||||||
|
rows = @db.execute( "select * from foo where a > 100" )
|
||||||
|
assert rows.empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute_with_block_no_bind_no_match
|
||||||
|
called = false
|
||||||
|
@db.execute( "select * from foo where a > 100" ) do |row|
|
||||||
|
called = true
|
||||||
|
end
|
||||||
|
assert !called
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute_no_block_with_bind_no_match
|
||||||
|
rows = @db.execute( "select * from foo where a > ?", 100 )
|
||||||
|
assert rows.empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute_with_block_with_bind_no_match
|
||||||
|
called = false
|
||||||
|
@db.execute( "select * from foo where a > ?", 100 ) do |row|
|
||||||
|
called = true
|
||||||
|
end
|
||||||
|
assert !called
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute_no_block_no_bind_with_match
|
||||||
|
rows = @db.execute( "select * from foo where a = 1" )
|
||||||
|
assert_equal 1, rows.length
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute_with_block_no_bind_with_match
|
||||||
|
called = 0
|
||||||
|
@db.execute( "select * from foo where a = 1" ) do |row|
|
||||||
|
called += 1
|
||||||
|
end
|
||||||
|
assert_equal 1, called
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute_no_block_with_bind_with_match
|
||||||
|
rows = @db.execute( "select * from foo where a = ?", 1 )
|
||||||
|
assert_equal 1, rows.length
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute_with_block_with_bind_with_match
|
||||||
|
called = 0
|
||||||
|
@db.execute( "select * from foo where a = ?", 1 ) do |row|
|
||||||
|
called += 1
|
||||||
|
end
|
||||||
|
assert_equal 1, called
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute2_no_block_no_bind_no_match
|
||||||
|
columns, *rows = @db.execute2( "select * from foo where a > 100" )
|
||||||
|
assert rows.empty?
|
||||||
|
assert [ "a", "b" ], columns
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute2_with_block_no_bind_no_match
|
||||||
|
called = 0
|
||||||
|
@db.execute2( "select * from foo where a > 100" ) do |row|
|
||||||
|
assert [ "a", "b" ], row unless called == 0
|
||||||
|
called += 1
|
||||||
|
end
|
||||||
|
assert_equal 1, called
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute2_no_block_with_bind_no_match
|
||||||
|
columns, *rows = @db.execute2( "select * from foo where a > ?", 100 )
|
||||||
|
assert rows.empty?
|
||||||
|
assert [ "a", "b" ], columns
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute2_with_block_with_bind_no_match
|
||||||
|
called = 0
|
||||||
|
@db.execute2( "select * from foo where a > ?", 100 ) do |row|
|
||||||
|
assert [ "a", "b" ], row unless called == 0
|
||||||
|
called += 1
|
||||||
|
end
|
||||||
|
assert_equal 1, called
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute2_no_block_no_bind_with_match
|
||||||
|
columns, *rows = @db.execute2( "select * from foo where a = 1" )
|
||||||
|
assert_equal 1, rows.length
|
||||||
|
assert [ "a", "b" ], columns
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute2_with_block_no_bind_with_match
|
||||||
|
called = 0
|
||||||
|
@db.execute2( "select * from foo where a = 1" ) do |row|
|
||||||
|
assert [ "a", "b" ], row unless called == 0
|
||||||
|
called += 1
|
||||||
|
end
|
||||||
|
assert_equal 2, called
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute2_no_block_with_bind_with_match
|
||||||
|
columns, *rows = @db.execute2( "select * from foo where a = ?", 1 )
|
||||||
|
assert_equal 1, rows.length
|
||||||
|
assert [ "a", "b" ], columns
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute2_with_block_with_bind_with_match
|
||||||
|
called = 0
|
||||||
|
@db.execute2( "select * from foo where a = ?", 1 ) do |row|
|
||||||
|
called += 1
|
||||||
|
end
|
||||||
|
assert_equal 2, called
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute_batch_empty
|
||||||
|
assert_nothing_raised { @db.execute_batch "" }
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute_batch_no_bind
|
||||||
|
@db.transaction do
|
||||||
|
@db.execute_batch <<-SQL
|
||||||
|
create table bar ( a, b, c );
|
||||||
|
insert into bar values ( 'one', 2, 'three' );
|
||||||
|
insert into bar values ( 'four', 5, 'six' );
|
||||||
|
insert into bar values ( 'seven', 8, 'nine' );
|
||||||
|
SQL
|
||||||
|
end
|
||||||
|
rows = @db.execute( "select * from bar" )
|
||||||
|
assert_equal 3, rows.length
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute_batch_with_bind
|
||||||
|
@db.execute_batch( <<-SQL, 1 )
|
||||||
|
create table bar ( a, b, c );
|
||||||
|
insert into bar values ( 'one', 2, ? );
|
||||||
|
insert into bar values ( 'four', 5, ? );
|
||||||
|
insert into bar values ( 'seven', 8, ? );
|
||||||
|
SQL
|
||||||
|
rows = @db.execute( "select * from bar" ).map { |a,b,c| c }
|
||||||
|
assert_equal %w{1 1 1}, rows
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_query_no_block_no_bind_no_match
|
||||||
|
result = @db.query( "select * from foo where a > 100" )
|
||||||
|
assert_nil result.next
|
||||||
|
result.close
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_query_with_block_no_bind_no_match
|
||||||
|
r = nil
|
||||||
|
@db.query( "select * from foo where a > 100" ) do |result|
|
||||||
|
assert_nil result.next
|
||||||
|
r = result
|
||||||
|
end
|
||||||
|
assert r.closed?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_query_no_block_with_bind_no_match
|
||||||
|
result = @db.query( "select * from foo where a > ?", 100 )
|
||||||
|
assert_nil result.next
|
||||||
|
result.close
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_query_with_block_with_bind_no_match
|
||||||
|
r = nil
|
||||||
|
@db.query( "select * from foo where a > ?", 100 ) do |result|
|
||||||
|
assert_nil result.next
|
||||||
|
r = result
|
||||||
|
end
|
||||||
|
assert r.closed?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_query_no_block_no_bind_with_match
|
||||||
|
result = @db.query( "select * from foo where a = 1" )
|
||||||
|
assert_not_nil result.next
|
||||||
|
assert_nil result.next
|
||||||
|
result.close
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_query_with_block_no_bind_with_match
|
||||||
|
r = nil
|
||||||
|
@db.query( "select * from foo where a = 1" ) do |result|
|
||||||
|
assert_not_nil result.next
|
||||||
|
assert_nil result.next
|
||||||
|
r = result
|
||||||
|
end
|
||||||
|
assert r.closed?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_query_no_block_with_bind_with_match
|
||||||
|
result = @db.query( "select * from foo where a = ?", 1 )
|
||||||
|
assert_not_nil result.next
|
||||||
|
assert_nil result.next
|
||||||
|
result.close
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_query_with_block_with_bind_with_match
|
||||||
|
r = nil
|
||||||
|
@db.query( "select * from foo where a = ?", 1 ) do |result|
|
||||||
|
assert_not_nil result.next
|
||||||
|
assert_nil result.next
|
||||||
|
r = result
|
||||||
|
end
|
||||||
|
assert r.closed?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_get_first_row_no_bind_no_match
|
||||||
|
result = @db.get_first_row( "select * from foo where a=100" )
|
||||||
|
assert_nil result
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_get_first_row_no_bind_with_match
|
||||||
|
result = @db.get_first_row( "select * from foo where a=1" )
|
||||||
|
assert_equal [ "1", "foo" ], result
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_get_first_row_with_bind_no_match
|
||||||
|
result = @db.get_first_row( "select * from foo where a=?", 100 )
|
||||||
|
assert_nil result
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_get_first_row_with_bind_with_match
|
||||||
|
result = @db.get_first_row( "select * from foo where a=?", 1 )
|
||||||
|
assert_equal [ "1", "foo" ], result
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_get_first_value_no_bind_no_match
|
||||||
|
result = @db.get_first_value( "select b, a from foo where a=100" )
|
||||||
|
assert_nil result
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_get_first_value_no_bind_with_match
|
||||||
|
result = @db.get_first_value( "select b, a from foo where a=1" )
|
||||||
|
assert_equal "foo", result
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_get_first_value_with_bind_no_match
|
||||||
|
result = @db.get_first_value( "select b, a from foo where a=?", 100 )
|
||||||
|
assert_nil result
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_get_first_value_with_bind_with_match
|
||||||
|
result = @db.get_first_value( "select b, a from foo where a=?", 1 )
|
||||||
|
assert_equal "foo", result
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_last_insert_row_id
|
||||||
|
@db.execute "insert into foo ( b ) values ( 'test' )"
|
||||||
|
assert_equal 4, @db.last_insert_row_id
|
||||||
|
@db.execute "insert into foo ( b ) values ( 'again' )"
|
||||||
|
assert_equal 5, @db.last_insert_row_id
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_changes
|
||||||
|
@db.execute "insert into foo ( b ) values ( 'test' )"
|
||||||
|
assert_equal 1, @db.changes
|
||||||
|
@db.execute "delete from foo where 1=1"
|
||||||
|
assert_equal 4, @db.changes
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_total_changes
|
||||||
|
assert_equal 3, @db.total_changes
|
||||||
|
@db.execute "insert into foo ( b ) values ( 'test' )"
|
||||||
|
@db.execute "delete from foo where 1=1"
|
||||||
|
assert_equal 8, @db.total_changes
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_transaction_nest
|
||||||
|
assert_raise( SQLite3::SQLException ) do
|
||||||
|
@db.transaction do
|
||||||
|
@db.transaction do
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_transaction_rollback
|
||||||
|
@db.transaction
|
||||||
|
@db.execute_batch <<-SQL
|
||||||
|
insert into foo (b) values ( 'test1' );
|
||||||
|
insert into foo (b) values ( 'test2' );
|
||||||
|
insert into foo (b) values ( 'test3' );
|
||||||
|
insert into foo (b) values ( 'test4' );
|
||||||
|
SQL
|
||||||
|
assert_equal 7, @db.get_first_value("select count(*) from foo").to_i
|
||||||
|
@db.rollback
|
||||||
|
assert_equal 3, @db.get_first_value("select count(*) from foo").to_i
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_transaction_commit
|
||||||
|
@db.transaction
|
||||||
|
@db.execute_batch <<-SQL
|
||||||
|
insert into foo (b) values ( 'test1' );
|
||||||
|
insert into foo (b) values ( 'test2' );
|
||||||
|
insert into foo (b) values ( 'test3' );
|
||||||
|
insert into foo (b) values ( 'test4' );
|
||||||
|
SQL
|
||||||
|
assert_equal 7, @db.get_first_value("select count(*) from foo").to_i
|
||||||
|
@db.commit
|
||||||
|
assert_equal 7, @db.get_first_value("select count(*) from foo").to_i
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_transaction_rollback_in_block
|
||||||
|
assert_raise( SQLite3::SQLException ) do
|
||||||
|
@db.transaction do
|
||||||
|
@db.rollback
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_transaction_commit_in_block
|
||||||
|
assert_raise( SQLite3::SQLException ) do
|
||||||
|
@db.transaction do
|
||||||
|
@db.commit
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_transaction_active
|
||||||
|
assert !@db.transaction_active?
|
||||||
|
@db.transaction
|
||||||
|
assert @db.transaction_active?
|
||||||
|
@db.commit
|
||||||
|
assert !@db.transaction_active?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_interrupt
|
||||||
|
@db.create_function( "abort", 1 ) do |func,x|
|
||||||
|
@db.interrupt
|
||||||
|
func.result = x
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_raise( SQLite3::SQLException ) do
|
||||||
|
@db.execute "select abort(a) from foo"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_create_function
|
||||||
|
@db.create_function( "munge", 1 ) do |func,x|
|
||||||
|
func.result = ">>>#{x}<<<"
|
||||||
|
end
|
||||||
|
|
||||||
|
value = @db.get_first_value( "select munge(b) from foo where a=1" )
|
||||||
|
assert_match( />>>.*<<</, value )
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_create_aggregate_without_block
|
||||||
|
step = proc do |ctx,a|
|
||||||
|
ctx[:sum] ||= 0
|
||||||
|
ctx[:sum] += a.to_i
|
||||||
|
end
|
||||||
|
|
||||||
|
final = proc { |ctx| ctx.result = ctx[:sum] }
|
||||||
|
|
||||||
|
@db.create_aggregate( "accumulate", 1, step, final )
|
||||||
|
|
||||||
|
value = @db.get_first_value( "select accumulate(a) from foo" )
|
||||||
|
assert_equal "6", value
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_create_aggregate_with_block
|
||||||
|
@db.create_aggregate( "accumulate", 1 ) do
|
||||||
|
step do |ctx,a|
|
||||||
|
ctx[:sum] ||= 0
|
||||||
|
ctx[:sum] += a.to_i
|
||||||
|
end
|
||||||
|
|
||||||
|
finalize { |ctx| ctx.result = ctx[:sum] }
|
||||||
|
end
|
||||||
|
|
||||||
|
value = @db.get_first_value( "select accumulate(a) from foo" )
|
||||||
|
assert_equal "6", value
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_create_aggregate_with_no_data
|
||||||
|
@db.create_aggregate( "accumulate", 1 ) do
|
||||||
|
step do |ctx,a|
|
||||||
|
ctx[:sum] ||= 0
|
||||||
|
ctx[:sum] += a.to_i
|
||||||
|
end
|
||||||
|
|
||||||
|
finalize { |ctx| ctx.result = ctx[:sum] || 0 }
|
||||||
|
end
|
||||||
|
|
||||||
|
value = @db.get_first_value(
|
||||||
|
"select accumulate(a) from foo where a = 100" )
|
||||||
|
assert_equal "0", value
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_create_aggregate_handler
|
||||||
|
handler = Class.new do
|
||||||
|
class << self
|
||||||
|
def arity; 1; end
|
||||||
|
def text_rep; SQLite3::Constants::TextRep::ANY; end
|
||||||
|
def name; "multiply"; end
|
||||||
|
end
|
||||||
|
def step(ctx, a)
|
||||||
|
ctx[:buffer] ||= 1
|
||||||
|
ctx[:buffer] *= a.to_i
|
||||||
|
end
|
||||||
|
def finalize(ctx); ctx.result = ctx[:buffer]; end
|
||||||
|
end
|
||||||
|
|
||||||
|
@db.create_aggregate_handler( handler )
|
||||||
|
value = @db.get_first_value( "select multiply(a) from foo" )
|
||||||
|
assert_equal "6", value
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_bind_array_parameter
|
||||||
|
result = @db.get_first_value( "select b from foo where a=? and b=?",
|
||||||
|
[ 1, "foo" ] )
|
||||||
|
assert_equal "foo", result
|
||||||
|
end
|
||||||
|
end
|
30
vendor/plugins/sqlite3-ruby/test/test_integration_open_close.rb
vendored
Normal file
30
vendor/plugins/sqlite3-ruby/test/test_integration_open_close.rb
vendored
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
require File.join(File.dirname(__FILE__), 'helper')
|
||||||
|
|
||||||
|
class TC_OpenClose < Test::Unit::TestCase
|
||||||
|
def test_create_close
|
||||||
|
begin
|
||||||
|
db = SQLite3::Database.new( "test-create.db" )
|
||||||
|
assert File.exist?( "test-create.db" )
|
||||||
|
assert_nothing_raised { db.close }
|
||||||
|
ensure
|
||||||
|
File.delete( "test-create.db" ) rescue nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_open_close
|
||||||
|
begin
|
||||||
|
File.open( "test-open.db", "w" ) { |f| }
|
||||||
|
assert File.exist?( "test-open.db" )
|
||||||
|
db = SQLite3::Database.new( "test-open.db" )
|
||||||
|
assert_nothing_raised { db.close }
|
||||||
|
ensure
|
||||||
|
File.delete( "test-open.db" ) rescue nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_bad_open
|
||||||
|
assert_raise( SQLite3::CantOpenException ) do
|
||||||
|
SQLite3::Database.new( "." )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
111
vendor/plugins/sqlite3-ruby/test/test_integration_pending.rb
vendored
Normal file
111
vendor/plugins/sqlite3-ruby/test/test_integration_pending.rb
vendored
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
require File.join(File.dirname(__FILE__), 'helper')
|
||||||
|
|
||||||
|
require 'thread'
|
||||||
|
require 'benchmark'
|
||||||
|
|
||||||
|
class TC_Integration_Pending < Test::Unit::TestCase
|
||||||
|
def setup
|
||||||
|
@db = SQLite3::Database.new( "test.db" )
|
||||||
|
@db.transaction do
|
||||||
|
@db.execute "create table foo ( a integer primary key, b text )"
|
||||||
|
@db.execute "insert into foo ( b ) values ( 'foo' )"
|
||||||
|
@db.execute "insert into foo ( b ) values ( 'bar' )"
|
||||||
|
@db.execute "insert into foo ( b ) values ( 'baz' )"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def teardown
|
||||||
|
@db.close
|
||||||
|
File.delete( "test.db" )
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_busy_handler_outwait
|
||||||
|
busy = Mutex.new
|
||||||
|
busy.lock
|
||||||
|
handler_call_count = 0
|
||||||
|
|
||||||
|
t = Thread.new(busy) do |locker|
|
||||||
|
begin
|
||||||
|
db2 = SQLite3::Database.open( "test.db" )
|
||||||
|
db2.transaction( :exclusive ) do
|
||||||
|
locker.lock
|
||||||
|
end
|
||||||
|
ensure
|
||||||
|
db2.close if db2
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@db.busy_handler do |data,count|
|
||||||
|
handler_call_count += 1
|
||||||
|
busy.unlock
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_nothing_raised do
|
||||||
|
@db.execute "insert into foo (b) values ( 'from 2' )"
|
||||||
|
end
|
||||||
|
|
||||||
|
t.join
|
||||||
|
|
||||||
|
assert_equal 1, handler_call_count
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_busy_handler_impatient
|
||||||
|
busy = Mutex.new
|
||||||
|
busy.lock
|
||||||
|
handler_call_count = 0
|
||||||
|
|
||||||
|
t = Thread.new do
|
||||||
|
begin
|
||||||
|
db2 = SQLite3::Database.open( "test.db" )
|
||||||
|
db2.transaction( :exclusive ) do
|
||||||
|
busy.lock
|
||||||
|
end
|
||||||
|
ensure
|
||||||
|
db2.close if db2
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@db.busy_handler do |data, count|
|
||||||
|
handler_call_count += 1
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_raise( SQLite3::BusyException ) do
|
||||||
|
@db.execute "insert into foo (b) values ( 'from 2' )"
|
||||||
|
end
|
||||||
|
|
||||||
|
busy.unlock
|
||||||
|
t.join
|
||||||
|
|
||||||
|
assert_equal 1, handler_call_count
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_busy_timeout
|
||||||
|
@db.busy_timeout 1000
|
||||||
|
busy = Mutex.new
|
||||||
|
busy.lock
|
||||||
|
|
||||||
|
t = Thread.new do
|
||||||
|
begin
|
||||||
|
db2 = SQLite3::Database.open( "test.db" )
|
||||||
|
db2.transaction( :exclusive ) do
|
||||||
|
busy.lock
|
||||||
|
end
|
||||||
|
ensure
|
||||||
|
db2.close if db2
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
time = Benchmark.measure do
|
||||||
|
assert_raise( SQLite3::BusyException ) do
|
||||||
|
@db.execute "insert into foo (b) values ( 'from 2' )"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
busy.unlock
|
||||||
|
t.join
|
||||||
|
|
||||||
|
assert time.real*1000 >= 1000
|
||||||
|
end
|
||||||
|
end
|
159
vendor/plugins/sqlite3-ruby/test/test_integration_resultset.rb
vendored
Normal file
159
vendor/plugins/sqlite3-ruby/test/test_integration_resultset.rb
vendored
Normal file
|
@ -0,0 +1,159 @@
|
||||||
|
require File.join(File.dirname(__FILE__), 'helper')
|
||||||
|
|
||||||
|
class TC_ResultSet < Test::Unit::TestCase
|
||||||
|
def setup
|
||||||
|
@db = SQLite3::Database.new( "test.db" )
|
||||||
|
@db.transaction do
|
||||||
|
@db.execute "create table foo ( a integer primary key, b text )"
|
||||||
|
@db.execute "insert into foo ( b ) values ( 'foo' )"
|
||||||
|
@db.execute "insert into foo ( b ) values ( 'bar' )"
|
||||||
|
@db.execute "insert into foo ( b ) values ( 'baz' )"
|
||||||
|
end
|
||||||
|
@stmt = @db.prepare( "select * from foo where a in ( ?, ? )" )
|
||||||
|
@result = @stmt.execute
|
||||||
|
end
|
||||||
|
|
||||||
|
def teardown
|
||||||
|
@stmt.close
|
||||||
|
@db.close
|
||||||
|
File.delete( "test.db" )
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_reset_unused
|
||||||
|
assert_nothing_raised { @result.reset }
|
||||||
|
assert @result.to_a.empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_reset_used
|
||||||
|
@result.to_a
|
||||||
|
assert_nothing_raised { @result.reset }
|
||||||
|
assert @result.to_a.empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_reset_with_bind
|
||||||
|
@result.to_a
|
||||||
|
assert_nothing_raised { @result.reset( 1, 2 ) }
|
||||||
|
assert_equal 2, @result.to_a.length
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_eof_inner
|
||||||
|
@result.reset( 1 )
|
||||||
|
assert !@result.eof?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_eof_edge
|
||||||
|
@result.reset( 1 )
|
||||||
|
@result.next # to first row
|
||||||
|
@result.next # to end of result set
|
||||||
|
assert @result.eof?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_next_eof
|
||||||
|
@result.reset( 1 )
|
||||||
|
assert_not_nil @result.next
|
||||||
|
assert_nil @result.next
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_next_no_type_translation_no_hash
|
||||||
|
@result.reset( 1 )
|
||||||
|
assert_equal [ "1", "foo" ], @result.next
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_next_type_translation
|
||||||
|
@db.type_translation = true
|
||||||
|
@result.reset( 1 )
|
||||||
|
assert_equal [ 1, "foo" ], @result.next
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_next_type_translation_with_untyped_column
|
||||||
|
@db.type_translation = true
|
||||||
|
@db.query( "select count(*) from foo" ) do |result|
|
||||||
|
assert_equal ["3"], result.next
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_type_translation_with_null_column
|
||||||
|
@db.type_translation = true
|
||||||
|
@db.execute "create table bar ( a integer, b time, c string )"
|
||||||
|
@db.execute "insert into bar (a, b, c) values (NULL, '1974-07-25 14:39:00', 'hello')"
|
||||||
|
@db.execute "insert into bar (a, b, c) values (1, NULL, 'hello')"
|
||||||
|
@db.execute "insert into bar (a, b, c) values (2, '1974-07-25 14:39:00', NULL)"
|
||||||
|
@db.query( "select * from bar" ) do |result|
|
||||||
|
assert_equal [nil, Time.local(1974, 7, 25, 14, 39, 0), 'hello'], result.next
|
||||||
|
assert_equal [1, nil, 'hello'], result.next
|
||||||
|
assert_equal [2, Time.local(1974, 7, 25, 14, 39, 0), nil], result.next
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_date_and_time_translation
|
||||||
|
@db.type_translation = true
|
||||||
|
@db.execute "create table bar ( a date, b datetime, c time, d timestamp )"
|
||||||
|
@db.execute "insert into bar (a, b, c, d) values ('1999-01-08', '1997-12-17 07:37:16', '07:37:16', '2004-10-19 10:23:54')"
|
||||||
|
@db.query( "select * from bar" ) do |result|
|
||||||
|
result = result.next
|
||||||
|
assert result[0].is_a?(Date)
|
||||||
|
assert result[1].is_a?(DateTime)
|
||||||
|
assert result[2].is_a?(Time)
|
||||||
|
assert result[3].is_a?(Time)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_next_results_as_hash
|
||||||
|
@db.results_as_hash = true
|
||||||
|
@result.reset( 1 )
|
||||||
|
assert_equal( { "a" => "1", "b" => "foo", 0 => "1", 1 => "foo" },
|
||||||
|
@result.next )
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_tainted_results_as_hash
|
||||||
|
@db.results_as_hash = true
|
||||||
|
@result.reset( 1 )
|
||||||
|
row = @result.next
|
||||||
|
row.each do |_, v|
|
||||||
|
assert_equal true, v.tainted?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_tainted_row_values
|
||||||
|
@result.reset( 1 )
|
||||||
|
row = @result.next
|
||||||
|
row.each do |v|
|
||||||
|
assert_equal true, v.tainted?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_each
|
||||||
|
called = 0
|
||||||
|
@result.reset( 1, 2 )
|
||||||
|
@result.each { |row| called += 1 }
|
||||||
|
assert_equal 2, called
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_enumerable
|
||||||
|
@result.reset( 1, 2 )
|
||||||
|
assert_equal 2, @result.to_a.length
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_types
|
||||||
|
assert_equal [ "integer", "text" ], @result.types
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_columns
|
||||||
|
assert_equal [ "a", "b" ], @result.columns
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_close
|
||||||
|
stmt = @db.prepare( "select * from foo" )
|
||||||
|
result = stmt.execute
|
||||||
|
assert !result.closed?
|
||||||
|
result.close
|
||||||
|
assert result.closed?
|
||||||
|
assert stmt.closed?
|
||||||
|
assert_raise( SQLite3::Exception ) { result.reset }
|
||||||
|
assert_raise( SQLite3::Exception ) { result.next }
|
||||||
|
assert_raise( SQLite3::Exception ) { result.each }
|
||||||
|
assert_raise( SQLite3::Exception ) { result.close }
|
||||||
|
assert_raise( SQLite3::Exception ) { result.types }
|
||||||
|
assert_raise( SQLite3::Exception ) { result.columns }
|
||||||
|
end
|
||||||
|
end
|
195
vendor/plugins/sqlite3-ruby/test/test_integration_statement.rb
vendored
Normal file
195
vendor/plugins/sqlite3-ruby/test/test_integration_statement.rb
vendored
Normal file
|
@ -0,0 +1,195 @@
|
||||||
|
require File.join(File.dirname(__FILE__), 'helper')
|
||||||
|
|
||||||
|
class TC_Statement < Test::Unit::TestCase
|
||||||
|
def setup
|
||||||
|
@db = SQLite3::Database.new( "test.db" )
|
||||||
|
@db.transaction do
|
||||||
|
@db.execute "create table foo ( a integer primary key, b text )"
|
||||||
|
@db.execute "insert into foo ( b ) values ( 'foo' )"
|
||||||
|
@db.execute "insert into foo ( b ) values ( 'bar' )"
|
||||||
|
@db.execute "insert into foo ( b ) values ( 'baz' )"
|
||||||
|
end
|
||||||
|
@stmt = @db.prepare( "select * from foo where a in ( ?, :named )" )
|
||||||
|
end
|
||||||
|
|
||||||
|
def teardown
|
||||||
|
@stmt.close
|
||||||
|
@db.close
|
||||||
|
File.delete( "test.db" )
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_remainder_empty
|
||||||
|
assert_equal "", @stmt.remainder
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_remainder_nonempty
|
||||||
|
called = false
|
||||||
|
@db.prepare( "select * from foo;\n blah" ) do |stmt|
|
||||||
|
called = true
|
||||||
|
assert_equal "\n blah", stmt.remainder
|
||||||
|
end
|
||||||
|
assert called
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_bind_params_empty
|
||||||
|
assert_nothing_raised { @stmt.bind_params }
|
||||||
|
assert @stmt.execute!.empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_bind_params_array
|
||||||
|
@stmt.bind_params 1, 2
|
||||||
|
assert_equal 2, @stmt.execute!.length
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_bind_params_hash
|
||||||
|
@stmt.bind_params ":named" => 2
|
||||||
|
assert_equal 1, @stmt.execute!.length
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_bind_params_hash_without_colon
|
||||||
|
@stmt.bind_params "named" => 2
|
||||||
|
assert_equal 1, @stmt.execute!.length
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_bind_params_hash_as_symbol
|
||||||
|
@stmt.bind_params :named => 2
|
||||||
|
assert_equal 1, @stmt.execute!.length
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_bind_params_mixed
|
||||||
|
@stmt.bind_params( 1, ":named" => 2 )
|
||||||
|
assert_equal 2, @stmt.execute!.length
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_bind_param_by_index
|
||||||
|
@stmt.bind_params( 1, 2 )
|
||||||
|
assert_equal 2, @stmt.execute!.length
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_bind_param_by_name_bad
|
||||||
|
assert_raise( SQLite3::Exception ) { @stmt.bind_param( "@named", 2 ) }
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_bind_param_by_name_good
|
||||||
|
@stmt.bind_param( ":named", 2 )
|
||||||
|
assert_equal 1, @stmt.execute!.length
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_bind_param_with_various_types
|
||||||
|
@db.transaction do
|
||||||
|
@db.execute "create table all_types ( a integer primary key, b float, c string, d integer )"
|
||||||
|
@db.execute "insert into all_types ( b, c, d ) values ( 1.4, 'hello', 68719476735 )"
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal 1, @db.execute( "select * from all_types where b = ?", 1.4 ).length
|
||||||
|
assert_equal 1, @db.execute( "select * from all_types where c = ?", 'hello').length
|
||||||
|
assert_equal 1, @db.execute( "select * from all_types where d = ?", 68719476735).length
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute_no_bind_no_block
|
||||||
|
assert_instance_of SQLite3::ResultSet, @stmt.execute
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute_with_bind_no_block
|
||||||
|
assert_instance_of SQLite3::ResultSet, @stmt.execute( 1, 2 )
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute_no_bind_with_block
|
||||||
|
called = false
|
||||||
|
@stmt.execute { |row| called = true }
|
||||||
|
assert called
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute_with_bind_with_block
|
||||||
|
called = 0
|
||||||
|
@stmt.execute( 1, 2 ) { |row| called += 1 }
|
||||||
|
assert_equal 1, called
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_reexecute
|
||||||
|
r = @stmt.execute( 1, 2 )
|
||||||
|
assert_equal 2, r.to_a.length
|
||||||
|
assert_nothing_raised { r = @stmt.execute( 1, 2 ) }
|
||||||
|
assert_equal 2, r.to_a.length
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute_bang_no_bind_no_block
|
||||||
|
assert @stmt.execute!.empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute_bang_with_bind_no_block
|
||||||
|
assert_equal 2, @stmt.execute!( 1, 2 ).length
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute_bang_no_bind_with_block
|
||||||
|
called = 0
|
||||||
|
@stmt.execute! { |row| called += 1 }
|
||||||
|
assert_equal 0, called
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute_bang_with_bind_with_block
|
||||||
|
called = 0
|
||||||
|
@stmt.execute!( 1, 2 ) { |row| called += 1 }
|
||||||
|
assert_equal 2, called
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_columns
|
||||||
|
c1 = @stmt.columns
|
||||||
|
c2 = @stmt.columns
|
||||||
|
assert_same c1, c2
|
||||||
|
assert_equal 2, c1.length
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_columns_computed
|
||||||
|
called = false
|
||||||
|
@db.prepare( "select count(*) from foo" ) do |stmt|
|
||||||
|
called = true
|
||||||
|
assert_equal [ "count(*)" ], stmt.columns
|
||||||
|
end
|
||||||
|
assert called
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_types
|
||||||
|
t1 = @stmt.types
|
||||||
|
t2 = @stmt.types
|
||||||
|
assert_same t1, t2
|
||||||
|
assert_equal 2, t1.length
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_types_computed
|
||||||
|
called = false
|
||||||
|
@db.prepare( "select count(*) from foo" ) do |stmt|
|
||||||
|
called = true
|
||||||
|
assert_equal [ nil ], stmt.types
|
||||||
|
end
|
||||||
|
assert called
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_close
|
||||||
|
stmt = @db.prepare( "select * from foo" )
|
||||||
|
assert !stmt.closed?
|
||||||
|
stmt.close
|
||||||
|
assert stmt.closed?
|
||||||
|
assert_raise( SQLite3::Exception ) { stmt.execute }
|
||||||
|
assert_raise( SQLite3::Exception ) { stmt.execute! }
|
||||||
|
assert_raise( SQLite3::Exception ) { stmt.close }
|
||||||
|
assert_raise( SQLite3::Exception ) { stmt.bind_params 5 }
|
||||||
|
assert_raise( SQLite3::Exception ) { stmt.bind_param 1, 5 }
|
||||||
|
assert_raise( SQLite3::Exception ) { stmt.columns }
|
||||||
|
assert_raise( SQLite3::Exception ) { stmt.types }
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_committing_tx_with_statement_active
|
||||||
|
called = false
|
||||||
|
@db.prepare( "select count(*) from foo" ) do |stmt|
|
||||||
|
called = true
|
||||||
|
count = stmt.execute!.first.first.to_i
|
||||||
|
@db.transaction do
|
||||||
|
@db.execute "insert into foo ( b ) values ( 'hello' )"
|
||||||
|
end
|
||||||
|
new_count = stmt.execute!.first.first.to_i
|
||||||
|
assert_equal new_count, count+1
|
||||||
|
end
|
||||||
|
assert called
|
||||||
|
end
|
||||||
|
end
|
6
vendor/plugins/sqlite3-ruby/test/tests.rb
vendored
6
vendor/plugins/sqlite3-ruby/test/tests.rb
vendored
|
@ -1,6 +0,0 @@
|
||||||
Dir.chdir File.dirname( __FILE__ )
|
|
||||||
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
|
|
||||||
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../ext/sqlite3_api"
|
|
||||||
p $LOAD_PATH
|
|
||||||
|
|
||||||
Dir["**/tc_*.rb"].each { |file| load file }
|
|
Loading…
Reference in a new issue