turso_libsql 0.1.1 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9042a62d9edb2a8d561a9abf342f023a5abb8645c77cbdacddfa02b7c733f389
4
- data.tar.gz: efb3bd164df4b1867a5fc94b0ee03984057b271f806a202fc9177cfbfc997001
3
+ metadata.gz: feeae4f9f6834be45e59f04689846b0f9d35317a5b2a573337919bea85ef4aa0
4
+ data.tar.gz: c1db75ecae4084c5a0d613dd3a33c3f9ff1f309e83e0ac3f2e2ed5a8ec2dbc95
5
5
  SHA512:
6
- metadata.gz: 674c3288de9c1bc6e3cafff199f2868f532776d3fa289302573a1ef1edc82687ffc6b8bab92cd44308d8a441bf436a69d068be886b86bdd455e6f6ad2ff21ba9
7
- data.tar.gz: 31298baac13d6b7f575d01db35fbee30a0d752819f9addf1b003a205e367174c8811fbc37425463fec8a556353376e0ba6cea0d2be2a3eef945c4784b530d857
6
+ metadata.gz: ad5bcd6581a6cd4df2498ec1f33f3e475837d47b9892fc773611ae80ad621effff9480113575d693df9792254ec0070c4111ab344550feb4d2eacee9be86ca84
7
+ data.tar.gz: 75228a8af12ea9a5026dd68054178793582e489e9b587e29e61d71df6ca5b18024ff08ebf8c8635e13f514ac0a281af539f1304a81db97359e514409fd4644a3
data/lib/libsql.rb CHANGED
@@ -50,6 +50,7 @@ module CLibsql # :nodoc:
50
50
  layout err: :pointer,
51
51
  inner: :pointer
52
52
 
53
+ def info = CLibsql.libsql_connection_info(self).tap(&:verify)
53
54
  def transaction = CLibsql.libsql_connection_transaction(self).tap(&:verify)
54
55
  def prepare(sql) = CLibsql.libsql_connection_prepare(self, sql).tap(&:verify)
55
56
  def execute_batch(sql) = CLibsql.libsql_connection_batch(self, sql).tap(&:verify)
@@ -109,6 +110,14 @@ module CLibsql # :nodoc:
109
110
  def deinit = CLibsql.libsql_row_deinit(self)
110
111
  end
111
112
 
113
+ class ConnectionInfo < FFI::Struct # :nodoc:
114
+ include Verify
115
+
116
+ layout err: :pointer,
117
+ last_inserted_id: :int64,
118
+ total_changes: :uint64
119
+ end
120
+
112
121
  class DatabaseDesc < FFI::Struct # :nodoc:
113
122
  layout url: :pointer,
114
123
  path: :pointer,
@@ -196,8 +205,6 @@ module CLibsql # :nodoc:
196
205
  end
197
206
 
198
207
  class Config < FFI::Struct # :nodoc:
199
- include Verify
200
-
201
208
  layout logger: :pointer,
202
209
  version: :pointer
203
210
  end
@@ -211,6 +218,7 @@ module CLibsql # :nodoc:
211
218
  attach_function :libsql_connection_transaction, [Connection.by_value], Transaction.by_value
212
219
  attach_function :libsql_connection_prepare, [Connection.by_value, :string], Statement.by_value
213
220
  attach_function :libsql_connection_batch, [Connection.by_value, :string], Batch.by_value
221
+ attach_function :libsql_connection_info, [Connection.by_value], ConnectionInfo.by_value
214
222
 
215
223
  attach_function :libsql_transaction_prepare, [Transaction.by_value, :string], Statement.by_value
216
224
  attach_function :libsql_transaction_commit, [Transaction.by_value], :void
@@ -256,12 +264,12 @@ module Libsql
256
264
  class ClosedException < Exception; end
257
265
 
258
266
  module Prepareable
259
- def execute(sql, params = [])
260
- prepare(sql) { |stmt| stmt.execute(params) }
267
+ def execute(sql, params = [], &block)
268
+ prepare(sql) { |stmt| stmt.execute(params, &block) }
261
269
  end
262
270
 
263
- def query(sql, params = [])
264
- prepare(sql) { |stmt| stmt.query(params) }
271
+ def query(sql, params = [], &block)
272
+ prepare(sql) { |stmt| stmt.query(params, &block) }
265
273
  end
266
274
  end
267
275
 
@@ -497,6 +505,18 @@ module Libsql
497
505
  end
498
506
  end
499
507
 
508
+ def total_changes
509
+ raise ClosedException if closed?
510
+
511
+ @inner.info[:total_changes]
512
+ end
513
+
514
+ def last_inserted_id
515
+ raise ClosedException if closed?
516
+
517
+ @inner.info[:last_inserted_id]
518
+ end
519
+
500
520
  def prepare(sql)
501
521
  raise ClosedException if closed?
502
522
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turso_libsql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Levy Albuquerque
@@ -67,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  requirements: []
70
- rubygems_version: 3.5.16
70
+ rubygems_version: 3.3.26
71
71
  signing_key:
72
72
  specification_version: 4
73
73
  summary: libSQL