sqlite3 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -7,8 +7,8 @@ begin
7
7
  require 'jeweler'
8
8
  Jeweler::Tasks.new do |gem|
9
9
  gem.name = "sqlite3"
10
- gem.summary = %Q{SQLite3/Ruby FFI bindings}
11
- gem.description = %Q{SQLite3/Ruby FFI bindings}
10
+ gem.summary = %Q{SQLite3 FFI bindings for Ruby 1.9}
11
+ gem.description = %Q{SQLite3 FFI bindings for Ruby 1.9}
12
12
  gem.email = "qoobaa@gmail.com"
13
13
  gem.homepage = "http://github.com/qoobaa/sqlite3"
14
14
  gem.authors = ["Jakub Kuźma"]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -11,7 +11,7 @@ module SQLite3
11
11
  "libsqlite3.dylib"
12
12
  when /linux|freebsd|netbsd|openbsd|dragonfly|solaris/
13
13
  "libsqlite3.so"
14
- when /win32/
14
+ when /win32|i386-mingw32/
15
15
  "sqlite3.dll"
16
16
  else
17
17
  abort <<-EOF
@@ -8,209 +8,209 @@ module SQLite3
8
8
  module Pragmas
9
9
 
10
10
  # Returns +true+ or +false+ depending on the value of the named pragma.
11
- def get_boolean_pragma(name)
12
- get_first_value("PRAGMA #{name}") != "0"
13
- end
14
- private :get_boolean_pragma
11
+ # def get_boolean_pragma(name)
12
+ # get_first_value("PRAGMA #{name}") != "0"
13
+ # end
14
+ # private :get_boolean_pragma
15
15
 
16
16
  # Sets the given pragma to the given boolean value. The value itself
17
17
  # may be +true+ or +false+, or any other commonly used string or
18
18
  # integer that represents truth.
19
- def set_boolean_pragma(name, mode)
20
- case mode
21
- when String
22
- case mode.downcase
23
- when "on", "yes", "true", "y", "t"
24
- mode = "'ON'"
25
- when "off", "no", "false", "n", "f"
26
- mode = "'OFF'"
27
- else
28
- raise Exception, "unrecognized pragma parameter #{mode.inspect}"
29
- end
30
- when true, 1
31
- mode = "ON"
32
- when false, 0, nil
33
- mode = "OFF"
34
- else
35
- raise Exception,
36
- "unrecognized pragma parameter #{mode.inspect}"
37
- end
38
-
39
- execute("PRAGMA #{name}=#{mode}")
40
- end
41
- private :set_boolean_pragma
19
+ # def set_boolean_pragma(name, mode)
20
+ # case mode
21
+ # when String
22
+ # case mode.downcase
23
+ # when "on", "yes", "true", "y", "t"
24
+ # mode = "'ON'"
25
+ # when "off", "no", "false", "n", "f"
26
+ # mode = "'OFF'"
27
+ # else
28
+ # raise Exception, "unrecognized pragma parameter #{mode.inspect}"
29
+ # end
30
+ # when true, 1
31
+ # mode = "ON"
32
+ # when false, 0, nil
33
+ # mode = "OFF"
34
+ # else
35
+ # raise Exception,
36
+ # "unrecognized pragma parameter #{mode.inspect}"
37
+ # end
38
+
39
+ # execute("PRAGMA #{name}=#{mode}")
40
+ # end
41
+ # private :set_boolean_pragma
42
42
 
43
43
  # Requests the given pragma (and parameters), and if the block is given,
44
44
  # each row of the result set will be yielded to it. Otherwise, the results
45
45
  # are returned as an array.
46
- def get_query_pragma(name, *parms, &block) # :yields: row
47
- if parms.empty?
48
- execute("PRAGMA #{name}", &block)
49
- else
50
- args = "'" + parms.join("','") + "'"
51
- execute("PRAGMA #{name}(#{args})", &block)
52
- end
53
- end
54
- private :get_query_pragma
46
+ # def get_query_pragma(name, *parms, &block) # :yields: row
47
+ # if parms.empty?
48
+ # execute("PRAGMA #{name}", &block)
49
+ # else
50
+ # args = "'" + parms.join("','") + "'"
51
+ # execute("PRAGMA #{name}(#{args})", &block)
52
+ # end
53
+ # end
54
+ # private :get_query_pragma
55
55
 
56
56
  # Return the value of the given pragma.
57
- def get_enum_pragma(name)
58
- get_first_value("PRAGMA #{name}")
59
- end
60
- private :get_enum_pragma
57
+ # def get_enum_pragma(name)
58
+ # get_first_value("PRAGMA #{name}")
59
+ # end
60
+ # private :get_enum_pragma
61
61
 
62
62
  # Set the value of the given pragma to +mode+. The +mode+ parameter must
63
63
  # conform to one of the values in the given +enum+ array. Each entry in
64
64
  # the array is another array comprised of elements in the enumeration that
65
65
  # have duplicate values. See #synchronous, #default_synchronous,
66
66
  # #temp_store, and #default_temp_store for usage examples.
67
- def set_enum_pragma(name, mode, enums)
68
- match = enums.find { |p| p.find { |i| i.to_s.downcase == mode.to_s.downcase } }
69
- raise Exception,
70
- "unrecognized #{name} #{mode.inspect}" unless match
71
- execute("PRAGMA #{name}='#{match.first.upcase}'")
72
- end
73
- private :set_enum_pragma
67
+ # def set_enum_pragma(name, mode, enums)
68
+ # match = enums.find { |p| p.find { |i| i.to_s.downcase == mode.to_s.downcase } }
69
+ # raise Exception,
70
+ # "unrecognized #{name} #{mode.inspect}" unless match
71
+ # execute("PRAGMA #{name}='#{match.first.upcase}'")
72
+ # end
73
+ # private :set_enum_pragma
74
74
 
75
75
  # Returns the value of the given pragma as an integer.
76
- def get_int_pragma(name)
77
- get_first_value("PRAGMA #{name}").to_i
78
- end
79
- private :get_int_pragma
76
+ # def get_int_pragma(name)
77
+ # get_first_value("PRAGMA #{name}").to_i
78
+ # end
79
+ # private :get_int_pragma
80
80
 
81
81
  # Set the value of the given pragma to the integer value of the +value+
82
82
  # parameter.
83
- def set_int_pragma(name, value)
84
- execute("PRAGMA #{name}=#{value.to_i}")
85
- end
86
- private :set_int_pragma
83
+ # def set_int_pragma(name, value)
84
+ # execute("PRAGMA #{name}=#{value.to_i}")
85
+ # end
86
+ # private :set_int_pragma
87
87
 
88
88
  # The enumeration of valid synchronous modes.
89
- SYNCHRONOUS_MODES = [ [ "full", 2 ], [ "normal", 1 ], [ "off", 0 ] ]
89
+ # SYNCHRONOUS_MODES = [ [ "full", 2 ], [ "normal", 1 ], [ "off", 0 ] ]
90
90
 
91
91
  # The enumeration of valid temp store modes.
92
- TEMP_STORE_MODES = [ [ "default", 0 ], [ "file", 1 ], [ "memory", 2 ] ]
92
+ # TEMP_STORE_MODES = [ [ "default", 0 ], [ "file", 1 ], [ "memory", 2 ] ]
93
93
 
94
94
  # Does an integrity check on the database. If the check fails, a
95
95
  # SQLite3::Exception will be raised. Otherwise it
96
96
  # returns silently.
97
- def integrity_check
98
- execute("PRAGMA integrity_check") do |row|
99
- raise Exception, row[0] if row[0] != "ok"
100
- end
101
- end
102
-
103
- def auto_vacuum
104
- get_boolean_pragma "auto_vacuum"
105
- end
106
-
107
- def auto_vacuum=(mode)
108
- set_boolean_pragma "auto_vacuum", mode
109
- end
110
-
111
- def schema_cookie
112
- get_int_pragma "schema_cookie"
113
- end
114
-
115
- def schema_cookie=(cookie)
116
- set_int_pragma "schema_cookie", cookie
117
- end
118
-
119
- def user_cookie
120
- get_int_pragma "user_cookie"
121
- end
122
-
123
- def user_cookie=(cookie)
124
- set_int_pragma "user_cookie", cookie
125
- end
126
-
127
- def cache_size
128
- get_int_pragma "cache_size"
129
- end
130
-
131
- def cache_size=(size)
132
- set_int_pragma "cache_size", size
133
- end
134
-
135
- def default_cache_size
136
- get_int_pragma "default_cache_size"
137
- end
97
+ # def integrity_check
98
+ # execute("PRAGMA integrity_check") do |row|
99
+ # raise Exception, row[0] if row[0] != "ok"
100
+ # end
101
+ # end
138
102
 
139
- def default_cache_size=(size)
140
- set_int_pragma "default_cache_size", size
141
- end
142
-
143
- def default_synchronous
144
- get_enum_pragma "default_synchronous"
145
- end
146
-
147
- def default_synchronous=(mode)
148
- set_enum_pragma "default_synchronous", mode, SYNCHRONOUS_MODES
149
- end
150
-
151
- def synchronous
152
- get_enum_pragma "synchronous"
153
- end
154
-
155
- def synchronous=(mode)
156
- set_enum_pragma "synchronous", mode, SYNCHRONOUS_MODES
157
- end
158
-
159
- def default_temp_store
160
- get_enum_pragma "default_temp_store"
161
- end
162
-
163
- def default_temp_store=(mode)
164
- set_enum_pragma "default_temp_store", mode, TEMP_STORE_MODES
165
- end
166
-
167
- def temp_store
168
- get_enum_pragma "temp_store"
169
- end
170
-
171
- def temp_store=(mode)
172
- set_enum_pragma "temp_store", mode, TEMP_STORE_MODES
173
- end
174
-
175
- def full_column_names
176
- get_boolean_pragma "full_column_names"
177
- end
178
-
179
- def full_column_names=(mode)
180
- set_boolean_pragma "full_column_names", mode
181
- end
182
-
183
- def parser_trace
184
- get_boolean_pragma "parser_trace"
185
- end
186
-
187
- def parser_trace=(mode)
188
- set_boolean_pragma "parser_trace", mode
189
- end
190
-
191
- def vdbe_trace
192
- get_boolean_pragma "vdbe_trace"
193
- end
103
+ # def auto_vacuum
104
+ # get_boolean_pragma "auto_vacuum"
105
+ # end
194
106
 
195
- def vdbe_trace=(mode)
196
- set_boolean_pragma "vdbe_trace", mode
197
- end
107
+ # def auto_vacuum=(mode)
108
+ # set_boolean_pragma "auto_vacuum", mode
109
+ # end
198
110
 
199
- def database_list(&block) # :yields: row
200
- get_query_pragma "database_list", &block
201
- end
111
+ # def schema_cookie
112
+ # get_int_pragma "schema_cookie"
113
+ # end
114
+
115
+ # def schema_cookie=(cookie)
116
+ # set_int_pragma "schema_cookie", cookie
117
+ # end
118
+
119
+ # def user_cookie
120
+ # get_int_pragma "user_cookie"
121
+ # end
122
+
123
+ # def user_cookie=(cookie)
124
+ # set_int_pragma "user_cookie", cookie
125
+ # end
126
+
127
+ # def cache_size
128
+ # get_int_pragma "cache_size"
129
+ # end
130
+
131
+ # def cache_size=(size)
132
+ # set_int_pragma "cache_size", size
133
+ # end
134
+
135
+ # def default_cache_size
136
+ # get_int_pragma "default_cache_size"
137
+ # end
138
+
139
+ # def default_cache_size=(size)
140
+ # set_int_pragma "default_cache_size", size
141
+ # end
142
+
143
+ # def default_synchronous
144
+ # get_enum_pragma "default_synchronous"
145
+ # end
146
+
147
+ # def default_synchronous=(mode)
148
+ # set_enum_pragma "default_synchronous", mode, SYNCHRONOUS_MODES
149
+ # end
150
+
151
+ # def synchronous
152
+ # get_enum_pragma "synchronous"
153
+ # end
154
+
155
+ # def synchronous=(mode)
156
+ # set_enum_pragma "synchronous", mode, SYNCHRONOUS_MODES
157
+ # end
158
+
159
+ # def default_temp_store
160
+ # get_enum_pragma "default_temp_store"
161
+ # end
162
+
163
+ # def default_temp_store=(mode)
164
+ # set_enum_pragma "default_temp_store", mode, TEMP_STORE_MODES
165
+ # end
166
+
167
+ # def temp_store
168
+ # get_enum_pragma "temp_store"
169
+ # end
170
+
171
+ # def temp_store=(mode)
172
+ # set_enum_pragma "temp_store", mode, TEMP_STORE_MODES
173
+ # end
174
+
175
+ # def full_column_names
176
+ # get_boolean_pragma "full_column_names"
177
+ # end
178
+
179
+ # def full_column_names=(mode)
180
+ # set_boolean_pragma "full_column_names", mode
181
+ # end
182
+
183
+ # def parser_trace
184
+ # get_boolean_pragma "parser_trace"
185
+ # end
186
+
187
+ # def parser_trace=(mode)
188
+ # set_boolean_pragma "parser_trace", mode
189
+ # end
190
+
191
+ # def vdbe_trace
192
+ # get_boolean_pragma "vdbe_trace"
193
+ # end
194
+
195
+ # def vdbe_trace=(mode)
196
+ # set_boolean_pragma "vdbe_trace", mode
197
+ # end
198
+
199
+ # def database_list(&block) # :yields: row
200
+ # get_query_pragma "database_list", &block
201
+ # end
202
202
 
203
- def foreign_key_list(table, &block) # :yields: row
204
- get_query_pragma "foreign_key_list", table, &block
205
- end
203
+ # def foreign_key_list(table, &block) # :yields: row
204
+ # get_query_pragma "foreign_key_list", table, &block
205
+ # end
206
206
 
207
- def index_info(index, &block) # :yields: row
208
- get_query_pragma "index_info", index, &block
209
- end
207
+ # def index_info(index, &block) # :yields: row
208
+ # get_query_pragma "index_info", index, &block
209
+ # end
210
210
 
211
- def index_list(table, &block) # :yields: row
212
- get_query_pragma "index_list", table, &block
213
- end
211
+ # def index_list(table, &block) # :yields: row
212
+ # get_query_pragma "index_list", table, &block
213
+ # end
214
214
 
215
215
  def table_info(table, &block) # :yields: row
216
216
  columns, *rows = execute2("PRAGMA table_info(#{table})")
@@ -29,6 +29,7 @@ class TestActiveRecord < Test::Unit::TestCase
29
29
  def setup
30
30
  ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
31
31
  ActiveRecord::Base.default_timezone = :utc
32
+ ActiveRecord::Migration.verbose = false
32
33
  CreateUsers.migrate(:up)
33
34
  end
34
35
 
@@ -90,4 +91,22 @@ class TestActiveRecord < Test::Unit::TestCase
90
91
  user = User.first
91
92
  assert_equal "alice", user.login
92
93
  end
94
+
95
+ def test_user_delete
96
+ User.create!(:login => "bob")
97
+ user = User.first
98
+ assert_equal "bob", user.login
99
+ user.destroy
100
+ assert_equal 0, User.count
101
+ end
102
+
103
+ def test_user_dirty_attributes
104
+ User.create!(:login => "bob")
105
+ user = User.first
106
+ assert_equal "bob", user.login
107
+ user.login = "alice"
108
+ assert user.login_changed?
109
+ assert_equal "alice", user.login
110
+ assert_equal "bob", user.login_was
111
+ end
93
112
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqlite3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Jakub Ku\xC5\xBAma"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-09 00:00:00 +01:00
12
+ date: 2009-12-20 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -42,7 +42,7 @@ dependencies:
42
42
  - !ruby/object:Gem::Version
43
43
  version: 2.3.5
44
44
  version:
45
- description: SQLite3/Ruby FFI bindings
45
+ description: SQLite3 FFI bindings for Ruby 1.9
46
46
  email: qoobaa@gmail.com
47
47
  executables: []
48
48
 
@@ -111,7 +111,7 @@ rubyforge_project:
111
111
  rubygems_version: 1.3.5
112
112
  signing_key:
113
113
  specification_version: 3
114
- summary: SQLite3/Ruby FFI bindings
114
+ summary: SQLite3 FFI bindings for Ruby 1.9
115
115
  test_files:
116
116
  - test/test_database_queries_utf_8.rb
117
117
  - test/test_database_queries_utf_16.rb