extralite 2.8 → 2.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4412f69118d15351524bd0065bc9c4624db0461bdc16b883ff4508e803b74ad4
4
- data.tar.gz: de354d27438bf9e93118fbe551c05c0bb11dd6713d70e58714209fa8f64b36d8
3
+ metadata.gz: b6b62d9130383d4b9c0f8d8efe4ef79b65ad848bd0c47bff3c24f42840f6312f
4
+ data.tar.gz: 40cad92b674fc3543786d66369a9fca9a0780888207fc067d2840f15017b4d9b
5
5
  SHA512:
6
- metadata.gz: 2bf2897e5545c4f701cc2efa49c00c68ee976c44d955261014f31a5c949408298a3848b5ba6b9ca35aaea144183f8746d7cee032ef259a0cf1bf2b75ca32fbd4
7
- data.tar.gz: de802356ba9f65089e1f9ff89b0af5d4032a8c5687ed33290b1ca0e4ff0bd8dbe8c674fe85a02eb1e94c2c5070b30db115aaef95d913a8d5bd4c51dbc68d62c6
6
+ metadata.gz: ff4217cf7915fdc5847fe5d12b6bbec5fe702b846e8fe4c4775aced9e63085ff63651ffcd261e8b69ad6e09ba3312cc62ac36985458afe8d67bb7c9128089f42
7
+ data.tar.gz: 7ebf114c561a9ee4783129442276ec48d5b43d708cc59c378bb37eb486d25d0999e7ade54c85d90b0e8cce40946f2efbc100c76cd83a395fbc31325d9d8419df
@@ -11,11 +11,13 @@ jobs:
11
11
  strategy:
12
12
  fail-fast: false
13
13
  matrix:
14
- os: [ubuntu-latest, macos-latest]
15
- ruby: ['3.0', '3.1', '3.2', '3.3']
14
+ # macos-latest uses arm64, macos-13 uses x86
15
+ os: [ubuntu-latest, macos-latest, macos-13]
16
+ ruby: ['3.0', '3.1', '3.2', '3.3', 'head']
16
17
 
17
- name: >-
18
- ${{matrix.os}}, ${{matrix.ruby}}
18
+ name: ${{matrix.os}}, ${{matrix.ruby}}
19
+
20
+ if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
19
21
 
20
22
  runs-on: ${{matrix.os}}
21
23
  steps:
@@ -11,11 +11,13 @@ jobs:
11
11
  strategy:
12
12
  fail-fast: false
13
13
  matrix:
14
- os: [ubuntu-latest, macos-latest]
14
+ # macos-latest uses arm64, macos-13 uses x86
15
+ os: [ubuntu-latest, macos-latest, macos-13]
15
16
  ruby: ['3.0', '3.1', '3.2', '3.3', 'head']
16
17
 
17
- name: >-
18
- ${{matrix.os}}, ${{matrix.ruby}}
18
+ name: ${{matrix.os}}, ${{matrix.ruby}}
19
+
20
+ if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
19
21
 
20
22
  runs-on: ${{matrix.os}}
21
23
  steps:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 2.8.2 2024-06-02
2
+
3
+ - Update bundled SQLite to version 3.46.0
4
+
5
+ ## 2.8.1 2024-04-15
6
+
7
+ - Update bundled sqlite to version 3.45.3.
8
+ - Fix `Database#execute` for SQL ending with a comment.
9
+ [#72](https://github.com/digital-fabric/extralite/pull/72)
10
+
1
11
  # 2.8 2024-03-10
2
12
 
3
13
  - Improve documentation.
data/README.md CHANGED
@@ -32,7 +32,7 @@ databases.
32
32
  Extralite comes in two flavors: the `extralite` gem which uses the
33
33
  system-installed sqlite3 library, and the `extralite-bundle` gem which bundles
34
34
  the latest version of SQLite
35
- ([3.45.0](https://sqlite.org/releaselog/3_45_0.html)), offering access to the
35
+ ([3.46.0](https://sqlite.org/releaselog/3_46_0.html)), offering access to the
36
36
  latest features and enhancements.
37
37
 
38
38
  ## Features
@@ -103,9 +103,9 @@ db2.pragma(journal_mode: :wal, synchronous: 1)
103
103
  db3 = Extralite::Database.new(fn)
104
104
  db3.pragma(journal_mode: :wal, synchronous: 1)
105
105
 
106
- db1.on_progress(1000) { |b| b ? sleep(0.0001) : snooze }
107
- db2.on_progress(1000) { |b| b ? sleep(0.0001) : snooze }
108
- db3.on_progress(1000) { |b| b ? sleep(0.0001) : snooze }
106
+ db1.on_progress { |b| b ? sleep(0.0001) : snooze }
107
+ db2.on_progress { |b| b ? sleep(0.0001) : snooze }
108
+ db3.on_progress { |b| b ? sleep(0.0001) : snooze }
109
109
 
110
110
  producer = PubSub.new(db1)
111
111
  producer.setup
@@ -163,7 +163,7 @@ end
163
163
 
164
164
  db4 = Extralite::Database.new(fn)
165
165
  db4.pragma(journal_mode: :wal, synchronous: 1)
166
- db4.on_progress(1000) { |busy| busy ? sleep(0.05) : snooze }
166
+ db4.on_progress { |busy| busy ? sleep(0.05) : snooze }
167
167
 
168
168
  last_t = Time.now
169
169
  last_publish_count = 0
@@ -175,7 +175,7 @@ while true
175
175
  d_publish = publish_count - last_publish_count
176
176
  d_receive = receive_count - last_receive_count
177
177
  pending = db4.query_single_splat('select count(*) from messages')
178
- puts "#{Time.now} publish: #{d_publish/elapsed}/s receive: #{d_receive/elapsed}/s pending: #{pending}"
178
+ puts "#{Time.now} publish: #{(d_publish/elapsed).round}/s receive: #{(d_receive/elapsed).round}/s pending: #{pending} latency: #{pending / (d_receive/elapsed)}"
179
179
  last_t = now
180
180
  last_publish_count = publish_count
181
181
  last_receive_count = receive_count
@@ -294,6 +294,8 @@ static inline VALUE Database_perform_query(int argc, VALUE *argv, VALUE self, VA
294
294
  prepare_multi_stmt(DB_GVL_MODE(db), db->sqlite3_db, &stmt, sql);
295
295
  RB_GC_GUARD(sql);
296
296
 
297
+ if (stmt == NULL) return Qnil;
298
+
297
299
  bind_all_parameters(stmt, argc - 1, argv + 1);
298
300
  query_ctx ctx = QUERY_CTX(
299
301
  self, sql, db, stmt, Qnil, transform,
@@ -485,6 +487,10 @@ VALUE Database_query_single_array(int argc, VALUE *argv, VALUE self) {
485
487
  * specified using keyword arguments:
486
488
  *
487
489
  * db.execute('update foo set x = :bar', bar: 42)
490
+ *
491
+ * @param sql [String] query SQL
492
+ * @param parameters [Array, Hash] parameters to run query with
493
+ * @return [Integer, nil] Total number of changes effected or `nil` if the query ends with a comment.
488
494
  */
489
495
  VALUE Database_execute(int argc, VALUE *argv, VALUE self) {
490
496
  return Database_perform_query(argc, argv, self, safe_query_changes, QUERY_HASH);
@@ -1,4 +1,4 @@
1
1
  module Extralite
2
2
  # Extralite version
3
- VERSION = '2.8'
3
+ VERSION = '2.8.2'
4
4
  end
Binary file
Binary file
Binary file
@@ -277,10 +277,14 @@ class DatabaseTest < Minitest::Test
277
277
 
278
278
  def test_extension_loading
279
279
  case RUBY_PLATFORM
280
- when /linux/
281
- @db.load_extension(File.join(__dir__, 'extensions/text.so'))
282
- when /darwin/
283
- @db.load_extension(File.join(__dir__, 'extensions/text.dylib'))
280
+ when /aarch64-linux/
281
+ @db.load_extension(File.join(__dir__, 'extensions/arm64/text.so'))
282
+ when /x86_64-linux/
283
+ @db.load_extension(File.join(__dir__, 'extensions/x86/text.so'))
284
+ when /arm64-darwin/
285
+ @db.load_extension(File.join(__dir__, 'extensions/arm64/text.dylib'))
286
+ when /x86_64-darwin/
287
+ @db.load_extension(File.join(__dir__, 'extensions/x86/text.dylib'))
284
288
  end
285
289
 
286
290
  r = @db.query_single_splat("select reverse('abcd')")
@@ -948,7 +952,7 @@ class DatabaseTest < Minitest::Test
948
952
 
949
953
  db.execute('insert into foo values (43)')
950
954
  assert_equal [42, 43], db.query_splat('select x from foo')
951
-
955
+
952
956
  db.savepoint(:b)
953
957
 
954
958
  db.execute('insert into foo values (44)')
@@ -1046,6 +1050,48 @@ class DatabaseTest < Minitest::Test
1046
1050
  assert File.size(wal_fn) == 0
1047
1051
  assert_equal [0, 0], r
1048
1052
  end
1053
+
1054
+ def test_execute_with_comments
1055
+ result = @db.execute(<<~SQL)
1056
+ -- this is a comment
1057
+ SQL
1058
+ assert_nil result
1059
+
1060
+ result = @db.execute(<<~SQL)
1061
+ DELETE FROM t;
1062
+ INSERT INTO t (x, y, z) VALUES (1, 1, 1);
1063
+ INSERT INTO t (x, y, z) VALUES (2, 2, 2);
1064
+ SQL
1065
+ assert_equal 1, result
1066
+ assert_equal [1, 2], @db.query_splat('SELECT x FROM t ORDER BY x')
1067
+
1068
+ result = @db.execute(<<~SQL)
1069
+ -- this is a comment at the beginning
1070
+ DELETE FROM t;
1071
+ INSERT INTO t (x, y, z) VALUES (3, 3, 3);
1072
+ INSERT INTO t (x, y, z) VALUES (4, 4, 4);
1073
+ SQL
1074
+ assert_equal 1, result
1075
+ assert_equal [3, 4], @db.query_splat('SELECT x FROM t ORDER BY x')
1076
+
1077
+ result = @db.execute(<<~SQL)
1078
+ DELETE FROM t;
1079
+ INSERT INTO t (x, y, z) VALUES (5, 5, 5);
1080
+ -- this is a comment in the middle
1081
+ INSERT INTO t (x, y, z) VALUES (6, 6, 6);
1082
+ SQL
1083
+ assert_equal 1, result
1084
+ assert_equal [5, 6], @db.query_splat('SELECT x FROM t ORDER BY x')
1085
+
1086
+ result = @db.execute(<<~SQL)
1087
+ DELETE FROM t;
1088
+ INSERT INTO t (x, y, z) VALUES (7, 7, 7);
1089
+ INSERT INTO t (x, y, z) VALUES (8, 8, 8);
1090
+ -- this is a comment at the end
1091
+ SQL
1092
+ assert_nil result
1093
+ assert_equal [7, 8], @db.query_splat('SELECT x FROM t ORDER BY x')
1094
+ end
1049
1095
  end
1050
1096
 
1051
1097
  class ScenarioTest < Minitest::Test
@@ -1438,7 +1484,7 @@ class ConcurrencyTest < Minitest::Test
1438
1484
 
1439
1485
  def test_progress_handler_invalid_arg
1440
1486
  db = Extralite::Database.new(':memory:')
1441
-
1487
+
1442
1488
  assert_raises(TypeError) { db.on_progress(period: :foo) }
1443
1489
  assert_raises(TypeError) { db.on_progress(tick: :foo) }
1444
1490
  assert_raises(ArgumentError) { db.on_progress(mode: :foo) }
@@ -1635,7 +1681,7 @@ end
1635
1681
  class RactorTest < Minitest::Test
1636
1682
  def test_ractor_simple
1637
1683
  skip if SKIP_RACTOR_TESTS
1638
-
1684
+
1639
1685
  fn = Tempfile.new('extralite_test_database_in_ractor').path
1640
1686
 
1641
1687
  r = Ractor.new do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: extralite
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.8'
4
+ version: 2.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-10 00:00:00.000000000 Z
11
+ date: 2024-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -123,8 +123,10 @@ files:
123
123
  - lib/extralite.rb
124
124
  - lib/extralite/version.rb
125
125
  - lib/sequel/adapters/extralite.rb
126
- - test/extensions/text.dylib
127
- - test/extensions/text.so
126
+ - test/extensions/arm64/text.dylib
127
+ - test/extensions/arm64/text.so
128
+ - test/extensions/x86/text.dylib
129
+ - test/extensions/x86/text.so
128
130
  - test/fixtures/image.png
129
131
  - test/helper.rb
130
132
  - test/issue-38.rb
Binary file