drizzle-sqlite 0.1.5

A type-safe SQL query builder for Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
//! Value conversion traits for SQLite types
//!
//! This module provides the `FromSQLiteValue` trait for converting SQLite values
//! to Rust types, and row capability traits for unified access across drivers.

use drizzle_core::error::DrizzleError;
use std::{rc::Rc, sync::Arc};

/// Trait for types that can be converted from SQLite values.
///
/// SQLite has 5 storage classes: NULL, INTEGER, REAL, TEXT, BLOB.
/// This trait provides conversion methods for each type.
///
/// # Implementation Notes
///
/// - Implement the methods that make sense for your type
/// - Return `Err` for unsupported conversions
/// - `SQLiteEnum` derive automatically implements this trait
pub trait FromSQLiteValue: Sized {
    /// Convert from a 64-bit integer value
    fn from_sqlite_integer(value: i64) -> Result<Self, DrizzleError>;

    /// Convert from a text/string value
    fn from_sqlite_text(value: &str) -> Result<Self, DrizzleError>;

    /// Convert from a real/float value
    fn from_sqlite_real(value: f64) -> Result<Self, DrizzleError>;

    /// Convert from a blob/binary value
    fn from_sqlite_blob(value: &[u8]) -> Result<Self, DrizzleError>;

    /// Convert from a NULL value (default returns error)
    fn from_sqlite_null() -> Result<Self, DrizzleError> {
        Err(DrizzleError::ConversionError(
            "unexpected NULL value".into(),
        ))
    }

    /// Helper function to convert from rusqlite's ValueRef using FromSQLiteValue
    #[cfg(feature = "rusqlite")]
    fn from_value_ref(value: ::rusqlite::types::ValueRef<'_>) -> Result<Self, DrizzleError> {
        match value {
            ::rusqlite::types::ValueRef::Null => Self::from_sqlite_null(),
            ::rusqlite::types::ValueRef::Integer(i) => Self::from_sqlite_integer(i),
            ::rusqlite::types::ValueRef::Real(r) => Self::from_sqlite_real(r),
            ::rusqlite::types::ValueRef::Text(text) => {
                let s = std::str::from_utf8(text).map_err(|e| {
                    DrizzleError::ConversionError(format!("invalid UTF-8: {}", e).into())
                })?;
                Self::from_sqlite_text(s)
            }
            ::rusqlite::types::ValueRef::Blob(blob) => Self::from_sqlite_blob(blob),
        }
    }
}

/// Row capability for index-based extraction.
pub trait DrizzleRowByIndex {
    /// Get a column value by index
    fn get_column<T: FromSQLiteValue>(&self, idx: usize) -> Result<T, DrizzleError>;
}

/// Optional row capability for name-based extraction.
pub trait DrizzleRowByName: DrizzleRowByIndex {
    /// Get a column value by name.
    fn get_column_by_name<T: FromSQLiteValue>(&self, name: &str) -> Result<T, DrizzleError>;
}

fn checked_real_to_int<T>(value: f64, type_name: &str) -> Result<T, DrizzleError>
where
    T: TryFrom<i128>,
    <T as TryFrom<i128>>::Error: core::fmt::Display,
{
    if !value.is_finite() {
        return Err(DrizzleError::ConversionError(
            format!("cannot convert non-finite REAL {} to {}", value, type_name).into(),
        ));
    }

    if value.fract() != 0.0 {
        return Err(DrizzleError::ConversionError(
            format!("cannot convert non-integer REAL {} to {}", value, type_name).into(),
        ));
    }

    if value < i128::MIN as f64 || value > i128::MAX as f64 {
        return Err(DrizzleError::ConversionError(
            format!("REAL {} out of range for {}", value, type_name).into(),
        ));
    }

    let int_value = value as i128;
    int_value.try_into().map_err(|e| {
        DrizzleError::ConversionError(
            format!("REAL {} out of range for {}: {}", value, type_name, e).into(),
        )
    })
}

// =============================================================================
// Primitive implementations
// =============================================================================

/// Macro to implement FromSQLiteValue for integer types (handles narrowing conversion from i64)
macro_rules! impl_from_sqlite_value_int {
    // Special case for i64 - no conversion needed
    (i64) => {
        impl FromSQLiteValue for i64 {
            fn from_sqlite_integer(value: i64) -> Result<Self, DrizzleError> {
                Ok(value)
            }

            fn from_sqlite_text(value: &str) -> Result<Self, DrizzleError> {
                value.parse().map_err(|e| {
                    DrizzleError::ConversionError(format!("cannot parse '{}' as i64: {}", value, e).into())
                })
            }

            fn from_sqlite_real(value: f64) -> Result<Self, DrizzleError> {
                checked_real_to_int(value, "i64")
            }

            fn from_sqlite_blob(_value: &[u8]) -> Result<Self, DrizzleError> {
                Err(DrizzleError::ConversionError("cannot convert BLOB to i64".into()))
            }
        }
    };
    // General case for other integer types - uses try_into for narrowing
    ($($ty:ty),+ $(,)?) => {
        $(
            impl FromSQLiteValue for $ty {
                fn from_sqlite_integer(value: i64) -> Result<Self, DrizzleError> {
                    value.try_into().map_err(|e| {
                        DrizzleError::ConversionError(
                            format!("i64 {} out of range for {}: {}", value, stringify!($ty), e).into(),
                        )
                    })
                }

                fn from_sqlite_text(value: &str) -> Result<Self, DrizzleError> {
                    value.parse().map_err(|e| {
                        DrizzleError::ConversionError(
                            format!("cannot parse '{}' as {}: {}", value, stringify!($ty), e).into()
                        )
                    })
                }

                fn from_sqlite_real(value: f64) -> Result<Self, DrizzleError> {
                    checked_real_to_int(value, stringify!($ty))
                }

                fn from_sqlite_blob(_value: &[u8]) -> Result<Self, DrizzleError> {
                    Err(DrizzleError::ConversionError(
                        concat!("cannot convert BLOB to ", stringify!($ty)).into()
                    ))
                }
            }
        )+
    };
}

/// Macro to implement FromSQLiteValue for float types
macro_rules! impl_from_sqlite_value_float {
    ($($ty:ty),+ $(,)?) => {
        $(
            impl FromSQLiteValue for $ty {
                fn from_sqlite_integer(value: i64) -> Result<Self, DrizzleError> {
                    Ok(value as $ty)
                }

                fn from_sqlite_text(value: &str) -> Result<Self, DrizzleError> {
                    value.parse().map_err(|e| {
                        DrizzleError::ConversionError(
                            format!("cannot parse '{}' as {}: {}", value, stringify!($ty), e).into()
                        )
                    })
                }

                fn from_sqlite_real(value: f64) -> Result<Self, DrizzleError> {
                    Ok(value as $ty)
                }

                fn from_sqlite_blob(_value: &[u8]) -> Result<Self, DrizzleError> {
                    Err(DrizzleError::ConversionError(
                        concat!("cannot convert BLOB to ", stringify!($ty)).into()
                    ))
                }
            }
        )+
    };
}

// Integer types
impl_from_sqlite_value_int!(i64);
impl_from_sqlite_value_int!(i8, i16, i32, isize, u8, u16, u32, u64, usize);

// Float types
impl_from_sqlite_value_float!(f32, f64);

impl FromSQLiteValue for bool {
    fn from_sqlite_integer(value: i64) -> Result<Self, DrizzleError> {
        Ok(value != 0)
    }

    fn from_sqlite_text(value: &str) -> Result<Self, DrizzleError> {
        match value.to_lowercase().as_str() {
            "true" | "1" | "yes" | "on" => Ok(true),
            "false" | "0" | "no" | "off" => Ok(false),
            _ => Err(DrizzleError::ConversionError(
                format!("cannot parse '{}' as bool", value).into(),
            )),
        }
    }

    fn from_sqlite_real(value: f64) -> Result<Self, DrizzleError> {
        Ok(value != 0.0)
    }

    fn from_sqlite_blob(_value: &[u8]) -> Result<Self, DrizzleError> {
        Err(DrizzleError::ConversionError(
            "cannot convert BLOB to bool".into(),
        ))
    }
}

impl FromSQLiteValue for String {
    fn from_sqlite_integer(value: i64) -> Result<Self, DrizzleError> {
        Ok(value.to_string())
    }

    fn from_sqlite_text(value: &str) -> Result<Self, DrizzleError> {
        Ok(value.to_string())
    }

    fn from_sqlite_real(value: f64) -> Result<Self, DrizzleError> {
        Ok(value.to_string())
    }

    fn from_sqlite_blob(value: &[u8]) -> Result<Self, DrizzleError> {
        String::from_utf8(value.to_vec()).map_err(|e| {
            DrizzleError::ConversionError(format!("invalid UTF-8 in BLOB: {}", e).into())
        })
    }
}

impl FromSQLiteValue for Box<String> {
    fn from_sqlite_integer(value: i64) -> Result<Self, DrizzleError> {
        String::from_sqlite_integer(value).map(Box::new)
    }

    fn from_sqlite_text(value: &str) -> Result<Self, DrizzleError> {
        String::from_sqlite_text(value).map(Box::new)
    }

    fn from_sqlite_real(value: f64) -> Result<Self, DrizzleError> {
        String::from_sqlite_real(value).map(Box::new)
    }

    fn from_sqlite_blob(value: &[u8]) -> Result<Self, DrizzleError> {
        String::from_sqlite_blob(value).map(Box::new)
    }
}

impl FromSQLiteValue for Rc<String> {
    fn from_sqlite_integer(value: i64) -> Result<Self, DrizzleError> {
        String::from_sqlite_integer(value).map(Rc::new)
    }

    fn from_sqlite_text(value: &str) -> Result<Self, DrizzleError> {
        String::from_sqlite_text(value).map(Rc::new)
    }

    fn from_sqlite_real(value: f64) -> Result<Self, DrizzleError> {
        String::from_sqlite_real(value).map(Rc::new)
    }

    fn from_sqlite_blob(value: &[u8]) -> Result<Self, DrizzleError> {
        String::from_sqlite_blob(value).map(Rc::new)
    }
}

impl FromSQLiteValue for Arc<String> {
    fn from_sqlite_integer(value: i64) -> Result<Self, DrizzleError> {
        String::from_sqlite_integer(value).map(Arc::new)
    }

    fn from_sqlite_text(value: &str) -> Result<Self, DrizzleError> {
        String::from_sqlite_text(value).map(Arc::new)
    }

    fn from_sqlite_real(value: f64) -> Result<Self, DrizzleError> {
        String::from_sqlite_real(value).map(Arc::new)
    }

    fn from_sqlite_blob(value: &[u8]) -> Result<Self, DrizzleError> {
        String::from_sqlite_blob(value).map(Arc::new)
    }
}

impl FromSQLiteValue for Box<str> {
    fn from_sqlite_integer(value: i64) -> Result<Self, DrizzleError> {
        String::from_sqlite_integer(value).map(String::into_boxed_str)
    }

    fn from_sqlite_text(value: &str) -> Result<Self, DrizzleError> {
        String::from_sqlite_text(value).map(String::into_boxed_str)
    }

    fn from_sqlite_real(value: f64) -> Result<Self, DrizzleError> {
        String::from_sqlite_real(value).map(String::into_boxed_str)
    }

    fn from_sqlite_blob(value: &[u8]) -> Result<Self, DrizzleError> {
        String::from_sqlite_blob(value).map(String::into_boxed_str)
    }
}

impl FromSQLiteValue for Rc<str> {
    fn from_sqlite_integer(value: i64) -> Result<Self, DrizzleError> {
        String::from_sqlite_integer(value).map(Rc::from)
    }

    fn from_sqlite_text(value: &str) -> Result<Self, DrizzleError> {
        String::from_sqlite_text(value).map(Rc::from)
    }

    fn from_sqlite_real(value: f64) -> Result<Self, DrizzleError> {
        String::from_sqlite_real(value).map(Rc::from)
    }

    fn from_sqlite_blob(value: &[u8]) -> Result<Self, DrizzleError> {
        String::from_sqlite_blob(value).map(Rc::from)
    }
}

impl FromSQLiteValue for Arc<str> {
    fn from_sqlite_integer(value: i64) -> Result<Self, DrizzleError> {
        String::from_sqlite_integer(value).map(Arc::from)
    }

    fn from_sqlite_text(value: &str) -> Result<Self, DrizzleError> {
        String::from_sqlite_text(value).map(Arc::from)
    }

    fn from_sqlite_real(value: f64) -> Result<Self, DrizzleError> {
        String::from_sqlite_real(value).map(Arc::from)
    }

    fn from_sqlite_blob(value: &[u8]) -> Result<Self, DrizzleError> {
        String::from_sqlite_blob(value).map(Arc::from)
    }
}

impl FromSQLiteValue for Vec<u8> {
    fn from_sqlite_integer(value: i64) -> Result<Self, DrizzleError> {
        Ok(value.to_le_bytes().to_vec())
    }

    fn from_sqlite_text(value: &str) -> Result<Self, DrizzleError> {
        Ok(value.as_bytes().to_vec())
    }

    fn from_sqlite_real(value: f64) -> Result<Self, DrizzleError> {
        Ok(value.to_le_bytes().to_vec())
    }

    fn from_sqlite_blob(value: &[u8]) -> Result<Self, DrizzleError> {
        Ok(value.to_vec())
    }
}

impl FromSQLiteValue for Box<Vec<u8>> {
    fn from_sqlite_integer(value: i64) -> Result<Self, DrizzleError> {
        Vec::<u8>::from_sqlite_integer(value).map(Box::new)
    }

    fn from_sqlite_text(value: &str) -> Result<Self, DrizzleError> {
        Vec::<u8>::from_sqlite_text(value).map(Box::new)
    }

    fn from_sqlite_real(value: f64) -> Result<Self, DrizzleError> {
        Vec::<u8>::from_sqlite_real(value).map(Box::new)
    }

    fn from_sqlite_blob(value: &[u8]) -> Result<Self, DrizzleError> {
        Vec::<u8>::from_sqlite_blob(value).map(Box::new)
    }
}

impl FromSQLiteValue for Rc<Vec<u8>> {
    fn from_sqlite_integer(value: i64) -> Result<Self, DrizzleError> {
        Vec::<u8>::from_sqlite_integer(value).map(Rc::new)
    }

    fn from_sqlite_text(value: &str) -> Result<Self, DrizzleError> {
        Vec::<u8>::from_sqlite_text(value).map(Rc::new)
    }

    fn from_sqlite_real(value: f64) -> Result<Self, DrizzleError> {
        Vec::<u8>::from_sqlite_real(value).map(Rc::new)
    }

    fn from_sqlite_blob(value: &[u8]) -> Result<Self, DrizzleError> {
        Vec::<u8>::from_sqlite_blob(value).map(Rc::new)
    }
}

impl FromSQLiteValue for Arc<Vec<u8>> {
    fn from_sqlite_integer(value: i64) -> Result<Self, DrizzleError> {
        Vec::<u8>::from_sqlite_integer(value).map(Arc::new)
    }

    fn from_sqlite_text(value: &str) -> Result<Self, DrizzleError> {
        Vec::<u8>::from_sqlite_text(value).map(Arc::new)
    }

    fn from_sqlite_real(value: f64) -> Result<Self, DrizzleError> {
        Vec::<u8>::from_sqlite_real(value).map(Arc::new)
    }

    fn from_sqlite_blob(value: &[u8]) -> Result<Self, DrizzleError> {
        Vec::<u8>::from_sqlite_blob(value).map(Arc::new)
    }
}

// Option<T> implementation - handles NULL values
impl<T: FromSQLiteValue> FromSQLiteValue for Option<T> {
    fn from_sqlite_integer(value: i64) -> Result<Self, DrizzleError> {
        T::from_sqlite_integer(value).map(Some)
    }

    fn from_sqlite_text(value: &str) -> Result<Self, DrizzleError> {
        T::from_sqlite_text(value).map(Some)
    }

    fn from_sqlite_real(value: f64) -> Result<Self, DrizzleError> {
        T::from_sqlite_real(value).map(Some)
    }

    fn from_sqlite_blob(value: &[u8]) -> Result<Self, DrizzleError> {
        T::from_sqlite_blob(value).map(Some)
    }

    fn from_sqlite_null() -> Result<Self, DrizzleError> {
        Ok(None)
    }
}

// =============================================================================
// Driver-specific DrizzleRow implementations
// =============================================================================

#[cfg(feature = "rusqlite")]
impl DrizzleRowByIndex for rusqlite::Row<'_> {
    fn get_column<T: FromSQLiteValue>(&self, idx: usize) -> Result<T, DrizzleError> {
        let value_ref = self.get_ref(idx)?;
        match value_ref {
            rusqlite::types::ValueRef::Integer(i) => T::from_sqlite_integer(i),
            rusqlite::types::ValueRef::Text(s) => {
                let s = std::str::from_utf8(s).map_err(|e| {
                    DrizzleError::ConversionError(format!("invalid UTF-8: {}", e).into())
                })?;
                T::from_sqlite_text(s)
            }
            rusqlite::types::ValueRef::Real(r) => T::from_sqlite_real(r),
            rusqlite::types::ValueRef::Blob(b) => T::from_sqlite_blob(b),
            rusqlite::types::ValueRef::Null => T::from_sqlite_null(),
        }
    }
}

#[cfg(feature = "rusqlite")]
impl DrizzleRowByName for rusqlite::Row<'_> {
    fn get_column_by_name<T: FromSQLiteValue>(&self, name: &str) -> Result<T, DrizzleError> {
        let idx = self.as_ref().column_index(name)?;
        DrizzleRowByIndex::get_column(self, idx)
    }
}

#[cfg(feature = "libsql")]
impl DrizzleRowByIndex for libsql::Row {
    fn get_column<T: FromSQLiteValue>(&self, idx: usize) -> Result<T, DrizzleError> {
        let value = self.get_value(idx as i32)?;
        match value {
            libsql::Value::Integer(i) => T::from_sqlite_integer(i),
            libsql::Value::Text(ref s) => T::from_sqlite_text(s),
            libsql::Value::Real(r) => T::from_sqlite_real(r),
            libsql::Value::Blob(ref b) => T::from_sqlite_blob(b),
            libsql::Value::Null => T::from_sqlite_null(),
        }
    }
}

#[cfg(feature = "turso")]
impl DrizzleRowByIndex for turso::Row {
    fn get_column<T: FromSQLiteValue>(&self, idx: usize) -> Result<T, DrizzleError> {
        let value = self.get_value(idx)?;
        if value.is_null() {
            T::from_sqlite_null()
        } else if let Some(&i) = value.as_integer() {
            T::from_sqlite_integer(i)
        } else if let Some(s) = value.as_text() {
            T::from_sqlite_text(s)
        } else if let Some(&r) = value.as_real() {
            T::from_sqlite_real(r)
        } else if let Some(b) = value.as_blob() {
            T::from_sqlite_blob(b)
        } else {
            Err(DrizzleError::ConversionError(
                "unknown SQLite value type".into(),
            ))
        }
    }
}

// =============================================================================
// UUID support (when feature enabled)
// =============================================================================

#[cfg(feature = "uuid")]
impl FromSQLiteValue for uuid::Uuid {
    fn from_sqlite_integer(_value: i64) -> Result<Self, DrizzleError> {
        Err(DrizzleError::ConversionError(
            "cannot convert INTEGER to UUID".into(),
        ))
    }

    fn from_sqlite_text(value: &str) -> Result<Self, DrizzleError> {
        uuid::Uuid::parse_str(value).map_err(|e| {
            DrizzleError::ConversionError(format!("invalid UUID string '{}': {}", value, e).into())
        })
    }

    fn from_sqlite_real(_value: f64) -> Result<Self, DrizzleError> {
        Err(DrizzleError::ConversionError(
            "cannot convert REAL to UUID".into(),
        ))
    }

    fn from_sqlite_blob(value: &[u8]) -> Result<Self, DrizzleError> {
        uuid::Uuid::from_slice(value)
            .map_err(|e| DrizzleError::ConversionError(format!("invalid UUID bytes: {}", e).into()))
    }
}

#[cfg(feature = "arrayvec")]
impl<const N: usize> FromSQLiteValue for arrayvec::ArrayString<N> {
    fn from_sqlite_integer(value: i64) -> Result<Self, DrizzleError> {
        let s = value.to_string();
        arrayvec::ArrayString::from(&s).map_err(|_| {
            DrizzleError::ConversionError(
                format!(
                    "String length {} exceeds ArrayString capacity {}",
                    s.len(),
                    N
                )
                .into(),
            )
        })
    }

    fn from_sqlite_text(value: &str) -> Result<Self, DrizzleError> {
        arrayvec::ArrayString::from(value).map_err(|_| {
            DrizzleError::ConversionError(
                format!(
                    "Text length {} exceeds ArrayString capacity {}",
                    value.len(),
                    N
                )
                .into(),
            )
        })
    }

    fn from_sqlite_real(value: f64) -> Result<Self, DrizzleError> {
        let s = value.to_string();
        arrayvec::ArrayString::from(&s).map_err(|_| {
            DrizzleError::ConversionError(
                format!(
                    "String length {} exceeds ArrayString capacity {}",
                    s.len(),
                    N
                )
                .into(),
            )
        })
    }

    fn from_sqlite_blob(value: &[u8]) -> Result<Self, DrizzleError> {
        let s = String::from_utf8(value.to_vec())
            .map_err(|e| DrizzleError::ConversionError(format!("invalid UTF-8: {}", e).into()))?;
        arrayvec::ArrayString::from(&s).map_err(|_| {
            DrizzleError::ConversionError(
                format!(
                    "String length {} exceeds ArrayString capacity {}",
                    s.len(),
                    N
                )
                .into(),
            )
        })
    }
}

#[cfg(feature = "arrayvec")]
impl<const N: usize> FromSQLiteValue for arrayvec::ArrayVec<u8, N> {
    fn from_sqlite_integer(_value: i64) -> Result<Self, DrizzleError> {
        Err(DrizzleError::ConversionError(
            "cannot convert INTEGER to ArrayVec<u8>, use BLOB".into(),
        ))
    }

    fn from_sqlite_text(_value: &str) -> Result<Self, DrizzleError> {
        Err(DrizzleError::ConversionError(
            "cannot convert TEXT to ArrayVec<u8>, use BLOB".into(),
        ))
    }

    fn from_sqlite_real(_value: f64) -> Result<Self, DrizzleError> {
        Err(DrizzleError::ConversionError(
            "cannot convert REAL to ArrayVec<u8>, use BLOB".into(),
        ))
    }

    fn from_sqlite_blob(value: &[u8]) -> Result<Self, DrizzleError> {
        arrayvec::ArrayVec::try_from(value).map_err(|_| {
            DrizzleError::ConversionError(
                format!(
                    "Blob length {} exceeds ArrayVec capacity {}",
                    value.len(),
                    N
                )
                .into(),
            )
        })
    }
}