sqlite3 1.5.0-arm-linux

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sqlite3 might be problematic. Click here for more details.

Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/.gemtest +0 -0
  3. data/API_CHANGES.md +49 -0
  4. data/CHANGELOG.md +425 -0
  5. data/CONTRIBUTING.md +24 -0
  6. data/ChangeLog.cvs +88 -0
  7. data/Gemfile +3 -0
  8. data/LICENSE +27 -0
  9. data/LICENSE-DEPENDENCIES +20 -0
  10. data/README.md +233 -0
  11. data/ext/sqlite3/aggregator.c +274 -0
  12. data/ext/sqlite3/aggregator.h +12 -0
  13. data/ext/sqlite3/backup.c +168 -0
  14. data/ext/sqlite3/backup.h +15 -0
  15. data/ext/sqlite3/database.c +853 -0
  16. data/ext/sqlite3/database.h +17 -0
  17. data/ext/sqlite3/exception.c +98 -0
  18. data/ext/sqlite3/exception.h +8 -0
  19. data/ext/sqlite3/extconf.rb +252 -0
  20. data/ext/sqlite3/sqlite3.c +163 -0
  21. data/ext/sqlite3/sqlite3_ruby.h +48 -0
  22. data/ext/sqlite3/statement.c +442 -0
  23. data/ext/sqlite3/statement.h +16 -0
  24. data/faq/faq.md +431 -0
  25. data/faq/faq.rb +145 -0
  26. data/faq/faq.yml +426 -0
  27. data/lib/sqlite3/2.6/sqlite3_native.so +0 -0
  28. data/lib/sqlite3/2.7/sqlite3_native.so +0 -0
  29. data/lib/sqlite3/3.0/sqlite3_native.so +0 -0
  30. data/lib/sqlite3/3.1/sqlite3_native.so +0 -0
  31. data/lib/sqlite3/constants.rb +50 -0
  32. data/lib/sqlite3/database.rb +741 -0
  33. data/lib/sqlite3/errors.rb +35 -0
  34. data/lib/sqlite3/pragmas.rb +595 -0
  35. data/lib/sqlite3/resultset.rb +187 -0
  36. data/lib/sqlite3/statement.rb +145 -0
  37. data/lib/sqlite3/translator.rb +118 -0
  38. data/lib/sqlite3/value.rb +57 -0
  39. data/lib/sqlite3/version.rb +23 -0
  40. data/lib/sqlite3.rb +15 -0
  41. data/test/helper.rb +27 -0
  42. data/test/test_backup.rb +33 -0
  43. data/test/test_collation.rb +82 -0
  44. data/test/test_database.rb +545 -0
  45. data/test/test_database_flags.rb +95 -0
  46. data/test/test_database_readonly.rb +36 -0
  47. data/test/test_database_readwrite.rb +41 -0
  48. data/test/test_deprecated.rb +44 -0
  49. data/test/test_encoding.rb +155 -0
  50. data/test/test_integration.rb +507 -0
  51. data/test/test_integration_aggregate.rb +336 -0
  52. data/test/test_integration_open_close.rb +30 -0
  53. data/test/test_integration_pending.rb +115 -0
  54. data/test/test_integration_resultset.rb +142 -0
  55. data/test/test_integration_statement.rb +194 -0
  56. data/test/test_result_set.rb +37 -0
  57. data/test/test_sqlite3.rb +30 -0
  58. data/test/test_statement.rb +263 -0
  59. data/test/test_statement_execute.rb +35 -0
  60. metadata +190 -0
@@ -0,0 +1,41 @@
1
+ require 'helper'
2
+
3
+ module SQLite3
4
+ class TestDatabaseReadwrite < SQLite3::TestCase
5
+ def setup
6
+ File.unlink 'test-readwrite.db' if File.exist?('test-readwrite.db')
7
+ @db = SQLite3::Database.new('test-readwrite.db')
8
+ @db.execute("CREATE TABLE foos (id integer)")
9
+ @db.close
10
+ end
11
+
12
+ def teardown
13
+ @db.close unless @db.closed?
14
+ File.unlink 'test-readwrite.db' if File.exist?('test-readwrite.db')
15
+ end
16
+
17
+ def test_open_readwrite_database
18
+ @db = SQLite3::Database.new('test-readwrite.db', :readwrite => true)
19
+ assert !@db.readonly?
20
+ end
21
+
22
+ def test_open_readwrite_readonly_database
23
+ assert_raise(RuntimeError) do
24
+ @db = SQLite3::Database.new('test-readwrite.db', :readwrite => true, :readonly => true)
25
+ end
26
+ end
27
+
28
+ def test_open_readwrite_not_exists_database
29
+ File.unlink 'test-readwrite.db'
30
+ assert_raise(SQLite3::CantOpenException) do
31
+ @db = SQLite3::Database.new('test-readwrite.db', :readonly => true)
32
+ end
33
+ end
34
+
35
+ def test_insert_readwrite_database
36
+ @db = SQLite3::Database.new('test-readwrite.db', :readwrite => true)
37
+ @db.execute("INSERT INTO foos (id) VALUES (12)")
38
+ assert @db.changes == 1
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,44 @@
1
+ require 'helper'
2
+
3
+ module SQLite3
4
+ class TestDeprecated < SQLite3::TestCase
5
+ attr_reader :db
6
+
7
+ def setup
8
+ super
9
+ @warn_before = $-w
10
+ $-w = false
11
+ @db = SQLite3::Database.new(':memory:')
12
+ @db.execute 'CREATE TABLE test_table (name text, age int)'
13
+ end
14
+
15
+ def teardown
16
+ super
17
+ $-w = @warn_before
18
+ end
19
+
20
+ def test_query_with_many_bind_params_not_nil
21
+ assert_equal [[1, 2]], db.query('select ?, ?', 1, 2).to_a
22
+ end
23
+
24
+ def test_execute_with_many_bind_params_not_nil
25
+ assert_equal [[1, 2]], @db.execute("select ?, ?", 1, 2).to_a
26
+ end
27
+
28
+ def test_query_with_many_bind_params
29
+ assert_equal [[nil, 1]], @db.query("select ?, ?", nil, 1).to_a
30
+ end
31
+
32
+ def test_query_with_nil_bind_params
33
+ assert_equal [['foo']], @db.query("select 'foo'", nil).to_a
34
+ end
35
+
36
+ def test_execute_with_many_bind_params
37
+ assert_equal [[nil, 1]], @db.execute("select ?, ?", nil, 1)
38
+ end
39
+
40
+ def test_execute_with_nil_bind_params
41
+ assert_equal [['foo']], @db.execute("select 'foo'", nil)
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,155 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'helper'
4
+
5
+ module SQLite3
6
+ class TestEncoding < SQLite3::TestCase
7
+ def setup
8
+ @db = SQLite3::Database.new(':memory:')
9
+ @create = "create table ex(id int, data string)"
10
+ @insert = "insert into ex(id, data) values (?, ?)"
11
+ @db.execute(@create);
12
+ end
13
+
14
+ def test_select_encoding_on_utf_16
15
+ str = "foo"
16
+ utf16 = ([1].pack("I") == [1].pack("N")) ? "UTF-16BE" : "UTF-16LE"
17
+ db = SQLite3::Database.new(':memory:'.encode(utf16))
18
+ db.execute @create
19
+ db.execute "insert into ex (id, data) values (1, \"#{str}\")"
20
+
21
+ stmt = db.prepare 'select * from ex where data = ?'
22
+ ['US-ASCII', utf16, 'EUC-JP', 'UTF-8'].each do |enc|
23
+ stmt.bind_param 1, str.encode(enc)
24
+ assert_equal 1, stmt.to_a.length
25
+ stmt.reset!
26
+ end
27
+ end
28
+
29
+ def test_insert_encoding
30
+ str = "foo"
31
+ utf16 = ([1].pack("I") == [1].pack("N")) ? "UTF-16BE" : "UTF-16LE"
32
+ db = SQLite3::Database.new(':memory:'.encode(utf16))
33
+ db.execute @create
34
+ stmt = db.prepare @insert
35
+
36
+ ['US-ASCII', utf16, 'EUC-JP', 'UTF-8'].each_with_index do |enc,i|
37
+ stmt.bind_param 1, i
38
+ stmt.bind_param 2, str.encode(enc)
39
+ stmt.to_a
40
+ stmt.reset!
41
+ end
42
+
43
+ db.execute('select data from ex').flatten.each do |s|
44
+ assert_equal str, s
45
+ end
46
+ end
47
+
48
+ def test_default_internal_is_honored
49
+ warn_before = $-w
50
+ $-w = false
51
+
52
+ before_enc = Encoding.default_internal
53
+
54
+ str = "壁に耳あり、障子に目あり"
55
+ stmt = @db.prepare('insert into ex(data) values (?)')
56
+ stmt.bind_param 1, str
57
+ stmt.step
58
+
59
+ Encoding.default_internal = 'EUC-JP'
60
+ string = @db.execute('select data from ex').first.first
61
+
62
+ assert_equal Encoding.default_internal, string.encoding
63
+ assert_equal str.encode('EUC-JP'), string
64
+ assert_equal str, string.encode(str.encoding)
65
+ ensure
66
+ Encoding.default_internal = before_enc
67
+ $-w = warn_before
68
+ end
69
+
70
+ def test_blob_is_binary
71
+ str = "猫舌"
72
+ @db.execute('create table foo(data text)')
73
+ stmt = @db.prepare('insert into foo(data) values (?)')
74
+ stmt.bind_param(1, SQLite3::Blob.new(str))
75
+ stmt.step
76
+
77
+ string = @db.execute('select data from foo').first.first
78
+ assert_equal Encoding.find('ASCII-8BIT'), string.encoding
79
+ assert_equal str, string.force_encoding('UTF-8')
80
+ end
81
+
82
+ def test_blob_is_ascii8bit
83
+ str = "猫舌"
84
+ @db.execute('create table foo(data text)')
85
+ stmt = @db.prepare('insert into foo(data) values (?)')
86
+ stmt.bind_param(1, str.dup.force_encoding("ASCII-8BIT"))
87
+ stmt.step
88
+
89
+ string = @db.execute('select data from foo').first.first
90
+ assert_equal Encoding.find('ASCII-8BIT'), string.encoding
91
+ assert_equal str, string.force_encoding('UTF-8')
92
+ end
93
+
94
+ def test_blob_with_eucjp
95
+ str = "猫舌".encode("EUC-JP")
96
+ @db.execute('create table foo(data text)')
97
+ stmt = @db.prepare('insert into foo(data) values (?)')
98
+ stmt.bind_param(1, SQLite3::Blob.new(str))
99
+ stmt.step
100
+
101
+ string = @db.execute('select data from foo').first.first
102
+ assert_equal Encoding.find('ASCII-8BIT'), string.encoding
103
+ assert_equal str, string.force_encoding('EUC-JP')
104
+ end
105
+
106
+ def test_db_with_eucjp
107
+ db = SQLite3::Database.new(':memory:'.encode('EUC-JP'))
108
+ assert_equal(Encoding.find('UTF-8'), db.encoding)
109
+ end
110
+
111
+ def test_db_with_utf16
112
+ utf16 = ([1].pack("I") == [1].pack("N")) ? "UTF-16BE" : "UTF-16LE"
113
+
114
+ db = SQLite3::Database.new(':memory:'.encode(utf16))
115
+ assert_equal(Encoding.find(utf16), db.encoding)
116
+ end
117
+
118
+ def test_statement_eucjp
119
+ str = "猫舌"
120
+ @db.execute("insert into ex(data) values ('#{str}')".encode('EUC-JP'))
121
+ row = @db.execute("select data from ex")
122
+ assert_equal @db.encoding, row.first.first.encoding
123
+ assert_equal str, row.first.first
124
+ end
125
+
126
+ def test_statement_utf8
127
+ str = "猫舌"
128
+ @db.execute("insert into ex(data) values ('#{str}')")
129
+ row = @db.execute("select data from ex")
130
+ assert_equal @db.encoding, row.first.first.encoding
131
+ assert_equal str, row.first.first
132
+ end
133
+
134
+ def test_encoding
135
+ assert_equal Encoding.find("UTF-8"), @db.encoding
136
+ end
137
+
138
+ def test_utf_8
139
+ str = "猫舌"
140
+ @db.execute(@insert, [10, str])
141
+ row = @db.execute("select data from ex")
142
+ assert_equal @db.encoding, row.first.first.encoding
143
+ assert_equal str, row.first.first
144
+ end
145
+
146
+ def test_euc_jp
147
+ str = "猫舌".encode('EUC-JP')
148
+ @db.execute(@insert, [10, str])
149
+ row = @db.execute("select data from ex")
150
+ assert_equal @db.encoding, row.first.first.encoding
151
+ assert_equal str.encode('UTF-8'), row.first.first
152
+ end
153
+
154
+ end if RUBY_VERSION >= '1.9.1'
155
+ end