turso_libsql 0.1.2 → 0.2.1

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: de0be6e4a1939210654efb34f3d5b4bd11ffc6f0e147eb834be31f98a83b9789
4
- data.tar.gz: 1dbc0222a2dbe3f61a2583a4751ce937535abfa6b6923d4664451920c612e940
3
+ metadata.gz: 5c771d247e215a74a9fdedcc98bf1a72988acbcc6eadf81430f1fbc16224a93b
4
+ data.tar.gz: bb1095381153f88cdae29edb953be1da8120b8e29d063f27b0a87a9183e83430
5
5
  SHA512:
6
- metadata.gz: 378198f7635a719b402a0e3f4e45602c37372ce75f079dc22e97b29f39b6487c4f04deab2b259b7482d9dc4ba3291f20ca29bb21a1edfd88490d5d549d8b96ce
7
- data.tar.gz: c71d6809b090d469faa2f3432d6a5c99dc850b81028fa29a3696c4755c4268127c3d7208ce1f211860a21718d86666c7621f6fb1933a5483b230e719cc3de957
6
+ metadata.gz: ea3f93e03e44a62b8181f99f5aedd41f6d2f3973006a9f8f9ef3a06c56f160d4d2fa5fbab30e08fc13fdb347f7fe8b3c44c9967ba2164c38f9faebf2e2037d46
7
+ data.tar.gz: b9f6f44c6f105669f0bc47c4638b6c0eed869b6811d836246df6257ac3da1c20d804ea54471f6c11f2a88555a4c58902d4e5765398ef0e6eb55b3db5b0c75baf
data/lib/libsql.rb CHANGED
@@ -6,6 +6,7 @@ module CLibsql # :nodoc:
6
6
  file =
7
7
  case RUBY_PLATFORM
8
8
  in /arm64-darwin/ then 'aarch64-apple-darwin/liblibsql.dylib'
9
+ in /x86_84-darwin/ then 'x86_64-apple-darwin/liblibsql.dylib'
9
10
  in /x86_64-linux/ then 'x86_64-unknown-linux-gnu/liblibsql.so'
10
11
  in /aarch64-linux/ then 'aarch64-unknown-linux-gnu/liblibsql.so'
11
12
  in /arm64-linux/ then 'aarch64-unknown-linux-gnu/liblibsql.so'
@@ -50,6 +51,7 @@ module CLibsql # :nodoc:
50
51
  layout err: :pointer,
51
52
  inner: :pointer
52
53
 
54
+ def info = CLibsql.libsql_connection_info(self).tap(&:verify)
53
55
  def transaction = CLibsql.libsql_connection_transaction(self).tap(&:verify)
54
56
  def prepare(sql) = CLibsql.libsql_connection_prepare(self, sql).tap(&:verify)
55
57
  def execute_batch(sql) = CLibsql.libsql_connection_batch(self, sql).tap(&:verify)
@@ -93,7 +95,7 @@ module CLibsql # :nodoc:
93
95
  def next = CLibsql.libsql_rows_next(self).tap(&:verify)
94
96
  def deinit = CLibsql.libsql_rows_deinit(self)
95
97
  def name_at(index) = CLibsql.libsql_rows_column_name(self, index)
96
- def length = CLibsql.libsql_rows_column_length(self)
98
+ def column_count = CLibsql.libsql_rows_column_count(self)
97
99
  end
98
100
 
99
101
  class Row < FFI::Struct # :nodoc:
@@ -109,6 +111,14 @@ module CLibsql # :nodoc:
109
111
  def deinit = CLibsql.libsql_row_deinit(self)
110
112
  end
111
113
 
114
+ class ConnectionInfo < FFI::Struct # :nodoc:
115
+ include Verify
116
+
117
+ layout err: :pointer,
118
+ last_inserted_id: :int64,
119
+ total_changes: :uint64
120
+ end
121
+
112
122
  class DatabaseDesc < FFI::Struct # :nodoc:
113
123
  layout url: :pointer,
114
124
  path: :pointer,
@@ -117,7 +127,9 @@ module CLibsql # :nodoc:
117
127
  sync_interval: :uint64,
118
128
  cypher: Cypher,
119
129
  disable_read_your_writes: :bool,
120
- webpki: :bool
130
+ webpki: :bool,
131
+ synced: :bool,
132
+ disable_safety_assert: :bool
121
133
  end
122
134
 
123
135
  class Bind < FFI::Struct # :nodoc:
@@ -209,6 +221,7 @@ module CLibsql # :nodoc:
209
221
  attach_function :libsql_connection_transaction, [Connection.by_value], Transaction.by_value
210
222
  attach_function :libsql_connection_prepare, [Connection.by_value, :string], Statement.by_value
211
223
  attach_function :libsql_connection_batch, [Connection.by_value, :string], Batch.by_value
224
+ attach_function :libsql_connection_info, [Connection.by_value], ConnectionInfo.by_value
212
225
 
213
226
  attach_function :libsql_transaction_prepare, [Transaction.by_value, :string], Statement.by_value
214
227
  attach_function :libsql_transaction_commit, [Transaction.by_value], :void
@@ -223,7 +236,7 @@ module CLibsql # :nodoc:
223
236
  attach_function :libsql_statement_reset, [Statement.by_value], :void
224
237
 
225
238
  attach_function :libsql_rows_next, [Rows.by_value], Row.by_value
226
- attach_function :libsql_rows_column_length, [Rows.by_value], :uint32
239
+ attach_function :libsql_rows_column_count, [Rows.by_value], :uint32
227
240
  attach_function :libsql_rows_column_name, [Rows.by_value, :uint32], Slice.by_value
228
241
 
229
242
  attach_function :libsql_row_empty, [Row.by_value], :bool
@@ -321,7 +334,7 @@ module Libsql
321
334
  def column_count
322
335
  raise ClosedException if closed?
323
336
 
324
- @inner.length
337
+ @inner.column_count
325
338
  end
326
339
 
327
340
  def columns
@@ -495,6 +508,18 @@ module Libsql
495
508
  end
496
509
  end
497
510
 
511
+ def total_changes
512
+ raise ClosedException if closed?
513
+
514
+ @inner.info[:total_changes]
515
+ end
516
+
517
+ def last_inserted_id
518
+ raise ClosedException if closed?
519
+
520
+ @inner.info[:last_inserted_id]
521
+ end
522
+
498
523
  def prepare(sql)
499
524
  raise ClosedException if closed?
500
525
 
@@ -527,8 +552,8 @@ module Libsql
527
552
  desc[sym] = FFI::MemoryPointer.from_string options[sym] unless options[sym].nil?
528
553
  end
529
554
 
530
- desc[:sync_interval] = options[:sync_interval] unless options[:sync_interval].nil?
531
- desc[:disable_read_your_writes] = !options[:read_your_writes] unless options[:read_your_writes].nil?
555
+ desc[:sync_interval] = options[:sync_interval] || 0
556
+ desc[:disable_read_your_writes] = !options[:read_your_writes] || true
532
557
 
533
558
  @inner = CLibsql::Database.init desc
534
559
 
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.2
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Levy Albuquerque