sqlite3 1.7.3 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +292 -0
  3. data/CONTRIBUTING.md +33 -7
  4. data/FAQ.md +43 -77
  5. data/INSTALLATION.md +14 -6
  6. data/LICENSE +18 -22
  7. data/README.md +97 -9
  8. data/dependencies.yml +10 -11
  9. data/ext/sqlite3/aggregator.c +142 -145
  10. data/ext/sqlite3/aggregator.h +2 -4
  11. data/ext/sqlite3/backup.c +74 -65
  12. data/ext/sqlite3/backup.h +2 -2
  13. data/ext/sqlite3/database.c +621 -493
  14. data/ext/sqlite3/database.h +13 -4
  15. data/ext/sqlite3/exception.c +116 -92
  16. data/ext/sqlite3/exception.h +5 -1
  17. data/ext/sqlite3/extconf.rb +33 -24
  18. data/ext/sqlite3/sqlite3.c +176 -115
  19. data/ext/sqlite3/sqlite3_ruby.h +2 -2
  20. data/ext/sqlite3/statement.c +553 -300
  21. data/ext/sqlite3/statement.h +4 -3
  22. data/ext/sqlite3/timespec.h +20 -0
  23. data/lib/sqlite3/constants.rb +195 -47
  24. data/lib/sqlite3/database.rb +223 -187
  25. data/lib/sqlite3/errors.rb +54 -1
  26. data/lib/sqlite3/fork_safety.rb +66 -0
  27. data/lib/sqlite3/pragmas.rb +140 -136
  28. data/lib/sqlite3/resultset.rb +14 -97
  29. data/lib/sqlite3/statement.rb +58 -13
  30. data/lib/sqlite3/value.rb +17 -20
  31. data/lib/sqlite3/version.rb +2 -21
  32. data/lib/sqlite3/version_info.rb +17 -0
  33. data/lib/sqlite3.rb +8 -4
  34. data/ports/archives/sqlite-autoconf-3470200.tar.gz +0 -0
  35. metadata +9 -37
  36. data/API_CHANGES.md +0 -49
  37. data/ChangeLog.cvs +0 -88
  38. data/Gemfile +0 -10
  39. data/LICENSE-DEPENDENCIES +0 -20
  40. data/lib/sqlite3/translator.rb +0 -117
  41. data/ports/archives/sqlite-autoconf-3450200.tar.gz +0 -0
  42. data/test/helper.rb +0 -27
  43. data/test/test_backup.rb +0 -33
  44. data/test/test_collation.rb +0 -82
  45. data/test/test_database.rb +0 -668
  46. data/test/test_database_flags.rb +0 -95
  47. data/test/test_database_readonly.rb +0 -36
  48. data/test/test_database_readwrite.rb +0 -41
  49. data/test/test_deprecated.rb +0 -49
  50. data/test/test_encoding.rb +0 -165
  51. data/test/test_integration.rb +0 -507
  52. data/test/test_integration_aggregate.rb +0 -336
  53. data/test/test_integration_open_close.rb +0 -30
  54. data/test/test_integration_pending.rb +0 -115
  55. data/test/test_integration_resultset.rb +0 -142
  56. data/test/test_integration_statement.rb +0 -194
  57. data/test/test_pragmas.rb +0 -22
  58. data/test/test_result_set.rb +0 -47
  59. data/test/test_sqlite3.rb +0 -30
  60. data/test/test_statement.rb +0 -290
  61. data/test/test_statement_execute.rb +0 -39
data/ChangeLog.cvs DELETED
@@ -1,88 +0,0 @@
1
- 2005-01-05 09:40 minam
2
-
3
- * Rakefile, sqlite3-ruby-win32.gemspec, sqlite3-ruby.gemspec: Added
4
- win32 gem.
5
-
6
- 2005-01-05 07:31 minam
7
-
8
- * Rakefile, test/tc_integration.rb, test/tests.rb: Added
9
- native-vs-dl benchmark to Rakefile. Added SQLITE3_DRIVERS
10
- environment variable to integration test to specify which
11
- driver(s) should be tested (defaults to "Native").
12
-
13
- 2005-01-04 14:26 minam
14
-
15
- * ext/sqlite3_api/sqlite3_api.i, lib/sqlite3/database.rb,
16
- lib/sqlite3/driver/native/driver.rb, test/tc_database.rb,
17
- test/tc_integration.rb, test/tests.rb: Unit tests: done. Bugs:
18
- fixed.
19
-
20
- 2005-01-03 23:13 minam
21
-
22
- * ext/sqlite3_api/sqlite3_api.i, lib/sqlite3/database.rb,
23
- lib/sqlite3/driver/dl/driver.rb,
24
- lib/sqlite3/driver/native/driver.rb, test/tc_integration.rb:
25
- Custom functions (aggregate and otherwise) are supported by the
26
- native driver now. Test cases for the same.
27
-
28
- 2005-01-03 13:51 minam
29
-
30
- * ext/sqlite3_api/MANIFEST, ext/sqlite3_api/extconf.rb,
31
- ext/sqlite3_api/post-clean.rb, ext/sqlite3_api/post-distclean.rb,
32
- ext/sqlite3_api/sqlite3_api.i, lib/sqlite3/database.rb,
33
- lib/sqlite3/resultset.rb, lib/sqlite3/version.rb,
34
- lib/sqlite3/driver/dl/driver.rb,
35
- lib/sqlite3/driver/native/driver.rb, test/native-vs-dl.rb,
36
- test/tc_integration.rb: Added preliminary implementation of
37
- native driver (swig-based), and integration tests.
38
-
39
- 2004-12-29 19:37 minam
40
-
41
- * lib/sqlite3/driver/dl/driver.rb: Some fixes to allow the DL
42
- driver to work with Ruby 1.8.1.
43
-
44
- 2004-12-29 14:52 minam
45
-
46
- * lib/sqlite3/: database.rb, version.rb: Made #quote a class method
47
- (again). Bumped version to 0.6.
48
-
49
- 2004-12-25 22:59 minam
50
-
51
- * lib/sqlite3/driver/dl/api.rb: Added check for darwin in supported
52
- platforms (thanks to bitsweat).
53
-
54
- 2004-12-22 12:38 minam
55
-
56
- * Rakefile: Rakefile wasn't packaging the README file.
57
-
58
- 2004-12-21 22:28 minam
59
-
60
- * Rakefile, sqlite3-ruby.gemspec, test/bm.rb: Packaging now works.
61
- Added benchmarks.
62
-
63
- 2004-12-21 21:45 minam
64
-
65
- * LICENSE, README, Rakefile, setup.rb, sqlite3-ruby.gemspec,
66
- doc/faq/faq.rb, doc/faq/faq.yml, lib/sqlite3.rb,
67
- lib/sqlite3/statement.rb, lib/sqlite3/constants.rb,
68
- lib/sqlite3/database.rb, lib/sqlite3/resultset.rb,
69
- lib/sqlite3/translator.rb, lib/sqlite3/value.rb,
70
- lib/sqlite3/version.rb, lib/sqlite3/errors.rb,
71
- lib/sqlite3/pragmas.rb, lib/sqlite3/driver/dl/api.rb,
72
- lib/sqlite3/driver/dl/driver.rb, test/mocks.rb,
73
- test/tc_database.rb, test/tests.rb, test/driver/dl/tc_driver.rb:
74
- Initial import
75
-
76
- 2004-12-21 21:45 minam
77
-
78
- * LICENSE, README, Rakefile, setup.rb, sqlite3-ruby.gemspec,
79
- doc/faq/faq.rb, doc/faq/faq.yml, lib/sqlite3.rb,
80
- lib/sqlite3/statement.rb, lib/sqlite3/constants.rb,
81
- lib/sqlite3/database.rb, lib/sqlite3/resultset.rb,
82
- lib/sqlite3/translator.rb, lib/sqlite3/value.rb,
83
- lib/sqlite3/version.rb, lib/sqlite3/errors.rb,
84
- lib/sqlite3/pragmas.rb, lib/sqlite3/driver/dl/api.rb,
85
- lib/sqlite3/driver/dl/driver.rb, test/mocks.rb,
86
- test/tc_database.rb, test/tests.rb, test/driver/dl/tc_driver.rb:
87
- Initial revision
88
-
data/Gemfile DELETED
@@ -1,10 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
4
-
5
- gem("minitest", "5.21.2")
6
- gem("rake-compiler", "1.2.5")
7
- gem("rake-compiler-dock", "1.4.0")
8
- gem("rdoc", "6.6.2")
9
-
10
- gem("ruby_memcheck", "2.3.0") if Gem::Platform.local.os == "linux"
data/LICENSE-DEPENDENCIES DELETED
@@ -1,20 +0,0 @@
1
- # Vendored Dependency Licenses
2
-
3
- The library `sqlite3-ruby` (which lives at https://github.com/sparklemotion/sqlite3-ruby) may include the source code for `sqlite` (which lives at https://www.sqlite.org/)
4
-
5
- `sqlite` source code is licensed under the public domain:
6
-
7
- > https://www.sqlite.org/copyright.html
8
-
9
- The license terms shipped with `sqlite` are included here for your convenience:
10
-
11
- ```
12
- The author disclaims copyright to this source code. In place of
13
- a legal notice, here is a blessing:
14
-
15
- May you do good and not evil.
16
- May you find forgiveness for yourself and forgive others.
17
- May you share freely, never taking more than you give.
18
- ```
19
-
20
- Note that these license terms do not apply to the `sqlite3-ruby` library itself.
@@ -1,117 +0,0 @@
1
- require 'time'
2
- require 'date'
3
-
4
- module SQLite3
5
-
6
- # The Translator class encapsulates the logic and callbacks necessary for
7
- # converting string data to a value of some specified type. Every Database
8
- # instance may have a Translator instance, in order to assist in type
9
- # translation (Database#type_translation).
10
- #
11
- # Further, applications may define their own custom type translation logic
12
- # by registering translator blocks with the corresponding database's
13
- # translator instance (Database#translator).
14
- class Translator
15
-
16
- # Create a new Translator instance. It will be preinitialized with default
17
- # translators for most SQL data types.
18
- def initialize
19
- @translators = Hash.new( proc { |type,value| value } )
20
- @type_name_cache = {}
21
- register_default_translators
22
- end
23
-
24
- # Add a new translator block, which will be invoked to process type
25
- # translations to the given type. The type should be an SQL datatype, and
26
- # may include parentheses (i.e., "VARCHAR(30)"). However, any parenthetical
27
- # information is stripped off and discarded, so type translation decisions
28
- # are made solely on the "base" type name.
29
- #
30
- # The translator block itself should accept two parameters, "type" and
31
- # "value". In this case, the "type" is the full type name (including
32
- # parentheses), so the block itself may include logic for changing how a
33
- # type is translated based on the additional data. The "value" parameter
34
- # is the (string) data to convert.
35
- #
36
- # The block should return the translated value.
37
- def add_translator( type, &block ) # :yields: type, value
38
- warn(<<-eowarn) if $VERBOSE
39
- #{caller[0]} is calling `SQLite3::Translator#add_translator`. Built-in translators are deprecated and will be removed in version 2.0.0.
40
- eowarn
41
- @translators[ type_name( type ) ] = block
42
- end
43
-
44
- # Translate the given string value to a value of the given type. In the
45
- # absence of an installed translator block for the given type, the value
46
- # itself is always returned. Further, +nil+ values are never translated,
47
- # and are always passed straight through regardless of the type parameter.
48
- def translate( type, value )
49
- unless value.nil?
50
- # FIXME: this is a hack to support Sequel
51
- if type && %w{ datetime timestamp }.include?(type.downcase)
52
- @translators[ type_name( type ) ].call( type, value.to_s )
53
- else
54
- @translators[ type_name( type ) ].call( type, value )
55
- end
56
- end
57
- end
58
-
59
- # A convenience method for working with type names. This returns the "base"
60
- # type name, without any parenthetical data.
61
- def type_name( type )
62
- @type_name_cache[type] ||= begin
63
- type = "" if type.nil?
64
- type = $1 if type =~ /^(.*?)\(/
65
- type.upcase
66
- end
67
- end
68
- private :type_name
69
-
70
- # Register the default translators for the current Translator instance.
71
- # This includes translators for most major SQL data types.
72
- def register_default_translators
73
- [ "time",
74
- "timestamp" ].each { |type| add_translator( type ) { |t, v| Time.parse( v ) } }
75
-
76
- add_translator( "date" ) { |t,v| Date.parse(v) }
77
- add_translator( "datetime" ) { |t,v| DateTime.parse(v) }
78
-
79
- [ "decimal",
80
- "float",
81
- "numeric",
82
- "double",
83
- "real",
84
- "dec",
85
- "fixed" ].each { |type| add_translator( type ) { |t,v| v.to_f } }
86
-
87
- [ "integer",
88
- "smallint",
89
- "mediumint",
90
- "int",
91
- "bigint" ].each { |type| add_translator( type ) { |t,v| v.to_i } }
92
-
93
- [ "bit",
94
- "bool",
95
- "boolean" ].each do |type|
96
- add_translator( type ) do |t,v|
97
- !( v.strip.gsub(/00+/,"0") == "0" ||
98
- v.downcase == "false" ||
99
- v.downcase == "f" ||
100
- v.downcase == "no" ||
101
- v.downcase == "n" )
102
- end
103
- end
104
-
105
- add_translator( "tinyint" ) do |type, value|
106
- if type =~ /\(\s*1\s*\)/
107
- value.to_i == 1
108
- else
109
- value.to_i
110
- end
111
- end
112
- end
113
- private :register_default_translators
114
-
115
- end
116
-
117
- end
data/test/helper.rb DELETED
@@ -1,27 +0,0 @@
1
- require 'sqlite3'
2
- require 'minitest/autorun'
3
-
4
- if ENV['GITHUB_ACTIONS'] == 'true' || ENV['CI']
5
- $VERBOSE = nil
6
- end
7
-
8
- puts "info: sqlite3-ruby version: #{SQLite3::VERSION}/#{SQLite3::VersionProxy::STRING}"
9
- puts "info: sqlite3 version: #{SQLite3::SQLITE_VERSION}/#{SQLite3::SQLITE_LOADED_VERSION}"
10
- puts "info: sqlcipher?: #{SQLite3.sqlcipher?}"
11
- puts "info: threadsafe?: #{SQLite3.threadsafe?}"
12
-
13
- unless RUBY_VERSION >= "1.9"
14
- require 'iconv'
15
- end
16
-
17
- module SQLite3
18
- class TestCase < Minitest::Test
19
- alias :assert_not_equal :refute_equal
20
- alias :assert_not_nil :refute_nil
21
- alias :assert_raise :assert_raises
22
-
23
- def assert_nothing_raised
24
- yield
25
- end
26
- end
27
- end
data/test/test_backup.rb DELETED
@@ -1,33 +0,0 @@
1
- require 'helper'
2
-
3
- module SQLite3
4
- class TestBackup < SQLite3::TestCase
5
- def setup
6
- @sdb = SQLite3::Database.new(':memory:')
7
- @ddb = SQLite3::Database.new(':memory:')
8
- @sdb.execute('CREATE TABLE foo (idx, val);');
9
- @data = ('A'..'Z').map{|x|x * 40}
10
- @data.each_with_index do |v, i|
11
- @sdb.execute('INSERT INTO foo (idx, val) VALUES (?, ?);', [i, v])
12
- end
13
- end
14
-
15
- def test_backup_step
16
- b = SQLite3::Backup.new(@ddb, 'main', @sdb, 'main')
17
- while b.step(1) == SQLite3::Constants::ErrorCode::OK
18
- assert_not_equal(0, b.remaining)
19
- end
20
- assert_equal(0, b.remaining)
21
- b.finish
22
- assert_equal(@data.length, @ddb.execute('SELECT * FROM foo;').length)
23
- end
24
-
25
- def test_backup_all
26
- b = SQLite3::Backup.new(@ddb, 'main', @sdb, 'main')
27
- assert_equal(SQLite3::Constants::ErrorCode::DONE, b.step(-1))
28
- assert_equal(0, b.remaining)
29
- b.finish
30
- assert_equal(@data.length, @ddb.execute('SELECT * FROM foo;').length)
31
- end
32
- end if defined?(SQLite3::Backup)
33
- end
@@ -1,82 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require 'helper'
4
-
5
- module SQLite3
6
- class TestCollation < SQLite3::TestCase
7
- class Comparator
8
- attr_reader :calls
9
- def initialize
10
- @calls = []
11
- end
12
-
13
- def compare left, right
14
- @calls << [left, right]
15
- left <=> right
16
- end
17
- end
18
-
19
- def setup
20
- @db = SQLite3::Database.new(':memory:')
21
- @create = "create table ex(id int, data string)"
22
- @db.execute(@create);
23
- [ [1, 'hello'], [2, 'world'] ].each do |vals|
24
- @db.execute('insert into ex (id, data) VALUES (?, ?)', vals)
25
- end
26
- end
27
-
28
- def test_custom_collation
29
- comparator = Comparator.new
30
-
31
- @db.collation 'foo', comparator
32
-
33
- assert_equal comparator, @db.collations['foo']
34
- @db.execute('select data from ex order by 1 collate foo')
35
- assert_equal 1, comparator.calls.length
36
- end
37
-
38
- def test_remove_collation
39
- comparator = Comparator.new
40
-
41
- @db.collation 'foo', comparator
42
- @db.collation 'foo', nil
43
-
44
- assert_nil @db.collations['foo']
45
- assert_raises(SQLite3::SQLException) do
46
- @db.execute('select data from ex order by 1 collate foo')
47
- end
48
- end
49
-
50
- if RUBY_VERSION >= '1.9.1'
51
- def test_encoding
52
- comparator = Comparator.new
53
- @db.collation 'foo', comparator
54
- @db.execute('select data from ex order by 1 collate foo')
55
-
56
- a, b = *comparator.calls.first
57
-
58
- assert_equal Encoding.find('UTF-8'), a.encoding
59
- assert_equal Encoding.find('UTF-8'), b.encoding
60
- end
61
-
62
- def test_encoding_default_internal
63
- warn_before = $-w
64
- $-w = false
65
- before_enc = Encoding.default_internal
66
-
67
- Encoding.default_internal = 'EUC-JP'
68
- comparator = Comparator.new
69
- @db.collation 'foo', comparator
70
- @db.execute('select data from ex order by 1 collate foo')
71
-
72
- a, b = *comparator.calls.first
73
-
74
- assert_equal Encoding.find('EUC-JP'), a.encoding
75
- assert_equal Encoding.find('EUC-JP'), b.encoding
76
- ensure
77
- Encoding.default_internal = before_enc
78
- $-w = warn_before
79
- end
80
- end
81
- end
82
- end