do_sqlite3 0.2.3 → 0.2.5
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.
- data/Rakefile +2 -2
- data/lib/do_sqlite3.rb +46 -1
- metadata +4 -4
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@ require 'rake/gempackagetask'
|
|
3
3
|
|
4
4
|
PLUGIN = "do_sqlite3"
|
5
5
|
NAME = "do_sqlite3"
|
6
|
-
VERSION = "0.2.
|
6
|
+
VERSION = "0.2.5"
|
7
7
|
AUTHOR = "Yehuda Katz"
|
8
8
|
EMAIL = "wycats@gmail.com"
|
9
9
|
HOMEPAGE = "http://dataobjects.devjavu.com"
|
@@ -20,7 +20,7 @@ spec = Gem::Specification.new do |s|
|
|
20
20
|
s.author = AUTHOR
|
21
21
|
s.email = EMAIL
|
22
22
|
s.homepage = HOMEPAGE
|
23
|
-
s.add_dependency('data_objects')
|
23
|
+
s.add_dependency('data_objects', ["<=0.2.0"])
|
24
24
|
s.require_path = 'lib'
|
25
25
|
s.autorequire = PLUGIN
|
26
26
|
s.extensions = ["ext/extconf.rb"]
|
data/lib/do_sqlite3.rb
CHANGED
@@ -38,6 +38,51 @@ module DataObject
|
|
38
38
|
Command.new(self, text)
|
39
39
|
end
|
40
40
|
|
41
|
+
def begin_transaction
|
42
|
+
Transaction.new(self)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
class Transaction < DataObject::Transaction
|
48
|
+
|
49
|
+
attr_reader :connection
|
50
|
+
|
51
|
+
def initialize(conn)
|
52
|
+
@connection = conn
|
53
|
+
exec_sql("BEGIN")
|
54
|
+
end
|
55
|
+
|
56
|
+
# Commits the transaction
|
57
|
+
def commit
|
58
|
+
exec_sql("COMMIT")
|
59
|
+
end
|
60
|
+
|
61
|
+
# Rolls back the transaction
|
62
|
+
def rollback(savepoint = nil)
|
63
|
+
raise NotImplementedError, "SQLite3 does not support savepoints" if savepoint
|
64
|
+
exec_sql("ROLLBACK")
|
65
|
+
end
|
66
|
+
|
67
|
+
# Creates a savepoint for rolling back later (not commonly supported)
|
68
|
+
def save(name)
|
69
|
+
raise NotImplementedError, "SQLite3 does not support savepoints"
|
70
|
+
end
|
71
|
+
|
72
|
+
def create_command(*args)
|
73
|
+
@connection.create_command(*args)
|
74
|
+
end
|
75
|
+
|
76
|
+
protected
|
77
|
+
|
78
|
+
def exec_sql(sql)
|
79
|
+
@connection.logger.debug { sql }
|
80
|
+
result, reader = Sqlite3_c.sqlite3_prepare_v2(@connection.db, sql, sql.size + 1)
|
81
|
+
exec_result = Sqlite3_c.sqlite3_step(reader)
|
82
|
+
Sqlite3_c.sqlite3_finalize(reader)
|
83
|
+
exec_result
|
84
|
+
end
|
85
|
+
|
41
86
|
end
|
42
87
|
|
43
88
|
class Reader < DataObject::Reader
|
@@ -162,4 +207,4 @@ module DataObject
|
|
162
207
|
end
|
163
208
|
|
164
209
|
end
|
165
|
-
end
|
210
|
+
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: do_sqlite3
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.2.
|
7
|
-
date: 2008-
|
6
|
+
version: 0.2.5
|
7
|
+
date: 2008-04-17 00:00:00 -07:00
|
8
8
|
summary: A DataObject.rb driver for sqlite3
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -57,7 +57,7 @@ dependencies:
|
|
57
57
|
version_requirement:
|
58
58
|
version_requirements: !ruby/object:Gem::Version::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - <=
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: 0.
|
62
|
+
version: 0.2.0
|
63
63
|
version:
|