extralite 2.1 → 2.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: bd8cf56eff701ddf57586d6f7510d5959cdf81ff15e6a64c6ed8ff698f93b43b
4
- data.tar.gz: 42000f8c83849577fd1672996969961357c5bbadb82d89d2168c74be7acfa303
3
+ metadata.gz: 53b2ae850ffcd04717090a536c2596c31976d73e31233dfad33a4db64fcbadfb
4
+ data.tar.gz: 611fa6336a8815347566b8b5559b2290a9a1dfa75943a6acca26c0c7b88f947b
5
5
  SHA512:
6
- metadata.gz: 1159c965d8ce9bfade2c81de97b6ef311dcfdb84ce65eb85238aa6a23b29b786d31de2bb8f30f87a24a800b88d01475a7cb400b97245401d587bef365b140087
7
- data.tar.gz: 74f975529a9efb7291524eaa4c285fadc6976377a607cd28e72cbd3010cbc9fd061264aabb9a5df1ce864f097ca330c9acd9dded62b8de7cc63c1217be88412a
6
+ metadata.gz: c6dc421bbd92ffb9c59c2c7a7d68865541e6f6ee52d73857c788485d84288efa85be605d4d1f510fce023d2cb292043d8142f8c953a01715066809d69482b0f3
7
+ data.tar.gz: 57116dce569018d2707424a89bdc63440eff4d3c1b9def37c8ab7f75a5083c12c718fd3f05b68455291e126f8077e05a3a6f52916c3627a324a85ce3f4b54eca
@@ -8,7 +8,7 @@ jobs:
8
8
  fail-fast: false
9
9
  matrix:
10
10
  os: [ubuntu-latest, macos-latest]
11
- ruby: ['2.7', '3.0', '3.1', '3.2', truffleruby]
11
+ ruby: ['2.7', '3.0', '3.1', '3.2', '3.3']
12
12
 
13
13
  name: >-
14
14
  ${{matrix.os}}, ${{matrix.ruby}}
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 2.2 2023-10-14
2
+
3
+ - Set correct encoding for strings values in query results (#27)
4
+ - Reset query after running it in Sequel adapter (#26)
5
+
1
6
  # 2.1 2023-07-11
2
7
 
3
8
  - Implement `Database#execute`, `Query#execute` for data-manipulation queries
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- extralite (2.1)
4
+ extralite (2.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,6 +1,8 @@
1
1
  #include <stdio.h>
2
2
  #include "extralite.h"
3
3
 
4
+ rb_encoding *UTF8_ENCODING;
5
+
4
6
  static inline VALUE get_column_value(sqlite3_stmt *stmt, int col, int type) {
5
7
  switch (type) {
6
8
  case SQLITE_NULL:
@@ -10,7 +12,7 @@ static inline VALUE get_column_value(sqlite3_stmt *stmt, int col, int type) {
10
12
  case SQLITE_FLOAT:
11
13
  return DBL2NUM(sqlite3_column_double(stmt, col));
12
14
  case SQLITE_TEXT:
13
- return rb_str_new_cstr((char *)sqlite3_column_text(stmt, col));
15
+ return rb_enc_str_new((char *)sqlite3_column_text(stmt, col), (long)sqlite3_column_bytes(stmt, col), UTF8_ENCODING);
14
16
  case SQLITE_BLOB:
15
17
  return rb_str_new((const char *)sqlite3_column_blob(stmt, col), (long)sqlite3_column_bytes(stmt, col));
16
18
  default:
@@ -807,4 +807,6 @@ void Init_ExtraliteDatabase(void) {
807
807
 
808
808
  SYM_read_only = ID2SYM(rb_intern("read_only"));
809
809
  rb_gc_register_mark_object(SYM_read_only);
810
+
811
+ UTF8_ENCODING = rb_utf8_encoding();
810
812
  }
@@ -3,6 +3,7 @@
3
3
 
4
4
  #include "ruby.h"
5
5
  #include "ruby/thread.h"
6
+ #include "ruby/encoding.h"
6
7
 
7
8
  #ifdef EXTRALITE_NO_BUNDLE
8
9
  #include <sqlite3.h>
@@ -92,6 +93,8 @@ typedef struct {
92
93
  #define QUERY_MODE(default) (rb_block_given_p() ? QUERY_YIELD : default)
93
94
  #define MULTI_ROW_P(mode) (mode == QUERY_MULTI_ROW)
94
95
 
96
+ extern rb_encoding *UTF8_ENCODING;
97
+
95
98
  VALUE safe_execute_multi(query_ctx *ctx);
96
99
  VALUE safe_query_ary(query_ctx *ctx);
97
100
  VALUE safe_query_changes(query_ctx *ctx);
@@ -1,4 +1,4 @@
1
1
  module Extralite
2
2
  # Extralite version
3
- VERSION = '2.1'
3
+ VERSION = '2.2'
4
4
  end
@@ -212,7 +212,11 @@ module Sequel
212
212
  case type
213
213
  when :select
214
214
  query = conn.prepare(sql, args)
215
- log_connection_yield(sql, conn, log_args){block.call(query.each, query.columns)}
215
+ begin
216
+ log_connection_yield(sql, conn, log_args){block.call(query.each, query.columns)}
217
+ ensure
218
+ query.reset
219
+ end
216
220
  when :insert
217
221
  log_connection_yield(sql, conn, log_args){conn.query(sql, args)}
218
222
  conn.last_insert_rowid
@@ -387,6 +387,13 @@ end
387
387
  db = Extralite::Database.new(':memory:')
388
388
  assert_match /^\#\<Extralite::Database:0x[0-9a-f]+ :memory:\>$/, db.inspect
389
389
  end
390
+
391
+ def test_string_encoding
392
+ db = Extralite::Database.new(':memory:')
393
+ v = db.query_single_value("select 'foo'")
394
+ assert_equal 'foo', v
395
+ assert_equal 'UTF-8', v.encoding.name
396
+ end
390
397
  end
391
398
 
392
399
  class ScenarioTest < MiniTest::Test
@@ -101,4 +101,17 @@ class IteratorTest < MiniTest::Test
101
101
  i = @query.each_ary
102
102
  assert_match /^\#\<Extralite::Iterator:0x[0-9a-f]+ ary\>$/, i.inspect
103
103
  end
104
+
105
+ def test_return_from_block_issue_26
106
+ db = Extralite::Database.new('/tmp/locked.db')
107
+
108
+ λ = ->(sql) {
109
+ db.prepare(sql).each { |r| r.each { |_, v| return v } }
110
+ }
111
+
112
+ 20.times do |i|
113
+ λ.('DROP TABLE IF EXISTS `test1`')
114
+ λ.('CREATE TABLE `test1` (`_id` integer NOT NULL PRIMARY KEY AUTOINCREMENT) STRICT')
115
+ end
116
+ end
104
117
  end
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.1'
4
+ version: '2.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-11 00:00:00.000000000 Z
11
+ date: 2023-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -80,7 +80,7 @@ dependencies:
80
80
  - - '='
81
81
  - !ruby/object:Gem::Version
82
82
  version: 5.51.0
83
- description:
83
+ description:
84
84
  email: sharon@noteflakes.com
85
85
  executables: []
86
86
  extensions:
@@ -136,7 +136,7 @@ metadata:
136
136
  documentation_uri: https://www.rubydoc.info/gems/extralite
137
137
  homepage_uri: https://github.com/digital-fabric/extralite
138
138
  changelog_uri: https://github.com/digital-fabric/extralite/blob/master/CHANGELOG.md
139
- post_install_message:
139
+ post_install_message:
140
140
  rdoc_options:
141
141
  - "--title"
142
142
  - extralite
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  version: '0'
157
157
  requirements: []
158
158
  rubygems_version: 3.4.1
159
- signing_key:
159
+ signing_key:
160
160
  specification_version: 4
161
161
  summary: Extra-lightweight SQLite3 wrapper for Ruby
162
162
  test_files: []