libsql2 0.1.4 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7538d8ca4a42d13f987ceece8d023b123414f527cf0502ea2107f29dbb4359ef
4
- data.tar.gz: 71860c4876c69791443a601f8708d0ddd6a75bd0840214a273b4ff42c6570c39
3
+ metadata.gz: c0781bc9d230dc294a8db2adabc205ef96e235eb852a98b7b60f2c485a4d53eb
4
+ data.tar.gz: 6052e8eda9cdefde4f171acdb23158a6b5d11f3778ca40d17f4b6726f8cdcc8a
5
5
  SHA512:
6
- metadata.gz: 306cdfd6b3cc8a89252b667c2fe32321159fcae1d57ee10049bc1aa57d0aa4be8f9b3b625192c4e7740edb8d74387116c151d9c07e51b7babafd0941ec1950bb
7
- data.tar.gz: 5776385df3240586c52ca0a37e8973037171d3e4b00ba48dfbe645fc7f4f025d6256f343a49eda62742cd6f66a1b7d9e2150be6b0512e05a2427fad3306f4b54
6
+ metadata.gz: db88ea38ab18f73e60c49f04a39bc63c25a389ab6643812995a5825318e926d6d746850efd7058ac1457350192bd3f6c4aef6d123757c4fb02ed18a9ab2f0590
7
+ data.tar.gz: 8096dea4e5b674fa3a33af40a810201e981eb8166c8766464054dc7fdc35219daddf37fd6f912837b8d59d67caf7a4f09c4e8f835e6e0b775c9cf07dda93e176
data/Cargo.lock CHANGED
@@ -947,7 +947,7 @@ dependencies = [
947
947
 
948
948
  [[package]]
949
949
  name = "libsql2"
950
- version = "0.1.0"
950
+ version = "0.1.5"
951
951
  dependencies = [
952
952
  "libsql",
953
953
  "magnus",
data/README.md CHANGED
@@ -132,6 +132,8 @@ end
132
132
 
133
133
  ## Type Mapping
134
134
 
135
+ ### Query Results (libSQL → Ruby)
136
+
135
137
  | libSQL Type | Ruby Type | Notes |
136
138
  |---|---|---|
137
139
  | INTEGER | `Integer` | Signed 64-bit |
@@ -140,6 +142,18 @@ end
140
142
  | BLOB | `Libsql::Blob` | `String` subclass with `ASCII-8BIT` encoding |
141
143
  | NULL | `nil` | |
142
144
 
145
+ ### Bind Parameters (Ruby → libSQL)
146
+
147
+ | Ruby Type | libSQL Type | Notes |
148
+ |---|---|---|
149
+ | `Integer` | INTEGER | |
150
+ | `Float` | REAL | |
151
+ | `true` / `false` | INTEGER (1 / 0) | SQLite convention — no native Boolean type |
152
+ | `String` (UTF-8 etc.) | TEXT | |
153
+ | `String` (ASCII-8BIT) | BLOB | Ruby convention for binary data |
154
+ | `Libsql::Blob` | BLOB | `String` subclass, checked before `String` |
155
+ | `nil` | NULL | |
156
+
143
157
  ## Development
144
158
 
145
159
  Requirements: Ruby >= 3.4, Rust >= 1.74, and a C compiler.
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "libsql2"
3
- version = "0.1.4"
3
+ version = "0.1.5"
4
4
  edition = "2021"
5
5
  publish = false
6
6
 
@@ -1,6 +1,7 @@
1
1
  use std::cell::RefCell;
2
2
  use std::sync::Arc;
3
3
 
4
+ use magnus::encoding::EncodingCapable;
4
5
  use magnus::{prelude::*, Error, RArray, RModule, RString, Ruby, TryConvert, Value};
5
6
  use tokio::runtime::Runtime;
6
7
 
@@ -197,14 +198,25 @@ pub(crate) fn ruby_array_to_params(val: &Value) -> Result<Vec<ParamValue>, Error
197
198
  } else if item.is_kind_of(ruby.class_float()) {
198
199
  let f: f64 = TryConvert::try_convert(item)?;
199
200
  params.push(ParamValue::Real(f));
201
+ } else if item.is_kind_of(ruby.class_true_class()) {
202
+ params.push(ParamValue::Integer(1));
203
+ } else if item.is_kind_of(ruby.class_false_class()) {
204
+ params.push(ParamValue::Integer(0));
200
205
  } else if is_blob(item) {
201
206
  // Blob is a String subclass — must check before String
202
207
  let rstr: RString = TryConvert::try_convert(item)?;
203
208
  let bytes = unsafe { rstr.as_slice() }.to_vec();
204
209
  params.push(ParamValue::Blob(bytes));
205
210
  } else if item.is_kind_of(ruby.class_string()) {
206
- let s: String = TryConvert::try_convert(item)?;
207
- params.push(ParamValue::Text(s));
211
+ let rstr: RString = TryConvert::try_convert(item)?;
212
+ if rstr.enc_get() == ruby.ascii8bit_encindex() {
213
+ // ASCII-8BIT String is treated as binary data
214
+ let bytes = unsafe { rstr.as_slice() }.to_vec();
215
+ params.push(ParamValue::Blob(bytes));
216
+ } else {
217
+ let s: String = TryConvert::try_convert(item)?;
218
+ params.push(ParamValue::Text(s));
219
+ }
208
220
  } else {
209
221
  return Err(Error::new(
210
222
  error::libsql_error(),
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Libsql
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.5"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libsql2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - speria-jp
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-03-17 00:00:00.000000000 Z
10
+ date: 2026-03-18 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rb_sys