drizzle 0.2.0

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
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
#![doc = include_str!("../README.md")]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(docsrs, feature(doc_cfg, rustdoc_internals))]
#![allow(
    unexpected_cfgs,
    unused_imports,
    unused_macros,
    unused_mut,
    dead_code,
    clippy::redundant_closure,
    clippy::needless_question_mark,
    clippy::duplicated_attributes,
    clippy::single_component_path_imports
)]

#[cfg(all(not(feature = "std"), feature = "alloc"))]
extern crate alloc;

#[macro_use]
mod builder;

#[macro_use]
mod macros;

#[macro_use]
mod transaction;

#[doc(hidden)]
pub(crate) use drizzle_builder_join_impl;
#[doc(hidden)]
pub(crate) use drizzle_pg_builder_join_impl;
#[doc(hidden)]
pub(crate) use drizzle_pg_builder_join_using_impl;

/// Result type for drizzle operations.
#[doc(inline)]
pub use drizzle_core::error::Result;

#[cfg(feature = "std")]
#[doc(inline)]
pub use drizzle_macros::include_migrations;
/// SQL template macro.
#[doc(inline)]
pub use drizzle_macros::sql;

// `#[drizzle::test]` is internal to drizzle's own test suite: its expansion
// calls `crate::common::helpers` in `tests/`, so it cannot work in other
// crates. It stays public only because that suite is a separate crate.
#[doc(hidden)]
pub use drizzle_macros::test;

/// Database dialect enum.
#[doc(inline)]
pub use drizzle_types::Dialect;

/// Identifier casing used by codegen (`camelCase` / `snake_case`).
///
/// Re-exported from [`drizzle_types::Casing`] alongside [`Dialect`] so the
/// two configuration enums are reachable through the same canonical path.
#[doc(inline)]
pub use drizzle_types::Casing;

/// Re-export const_format for proc macro generated compile-time SQL.
#[doc(hidden)]
pub use const_format;

/// Error types.
pub mod error {
    #[doc(inline)]
    pub use drizzle_core::error::DrizzleError;
}

/// DDL types and schema definitions.
pub mod ddl {
    #[doc(inline)]
    pub use drizzle_types::mysql;
    #[doc(inline)]
    pub use drizzle_types::postgres;
    #[doc(inline)]
    pub use drizzle_types::sqlite;
}

/// Migration helpers and schema snapshots.
#[cfg(feature = "std")]
pub mod migrations {
    #[doc(inline)]
    pub use drizzle_migrations::*;
}

/// Core traits, SQL types, and expressions shared across drivers.
pub mod core {
    /// SQL building blocks.
    #[doc(inline)]
    pub use drizzle_core::{
        ColumnDialect, ColumnFlags, ColumnRef, ConstraintRef, Derived, DerivedField, ForeignKeyRef,
        OrderBy, Param, ParamBind, ParamSet, Placeholder, PrimaryKeyRef, SQL, SQLChunk,
        TableDialect, TableRef, TableSqlRef, Token, TypedPlaceholder, asc, desc,
    };

    /// Conversion trait for SQL generation.
    #[doc(inline)]
    pub use drizzle_core::ToSQL;

    /// Core traits (`SQLTable`, `SQLColumn`, `SQLSchema`, `SQLModel`, etc.).
    #[doc(inline)]
    pub use drizzle_core::traits::*;

    /// Relation metadata types and traits.
    #[doc(inline)]
    pub use drizzle_core::relation::{Joinable, Relation, SchemaHasTable};

    /// Full relation module exports.
    pub mod relation {
        #[doc(inline)]
        pub use drizzle_core::relation::*;
    }

    /// Prepared statement types.
    #[doc(inline)]
    pub use drizzle_core::prepared::{OwnedPreparedStatement, PreparedStatement};

    /// SQL type markers used by expressions.
    #[doc(inline)]
    pub use drizzle_core::types;

    /// Type-safe expressions and helpers.
    #[doc(inline)]
    pub use drizzle_core::expr;

    #[doc(hidden)]
    pub use drizzle_core::impl_try_from_int;

    #[doc(hidden)]
    pub use drizzle_core::schema::SQLEnumInfo;

    #[doc(hidden)]
    pub use drizzle_core::{
        ColumnScope, InsertColumn, InsertSelectAllColumns, InsertSelectTable, OpaqueScope,
        ProjectionInScope, ScopeContains,
    };

    /// Bind parameter type mapping trait.
    #[doc(inline)]
    pub use drizzle_core::ValueTypeForDialect;

    /// Dialect markers (`SQLiteDialect`, `PostgresDialect`, etc.).
    pub mod dialect {
        #[doc(inline)]
        pub use drizzle_core::dialect::*;
    }

    /// Query API types (relational queries with nested loading).
    #[cfg(feature = "query")]
    pub mod query {
        #[doc(inline)]
        pub use drizzle_core::query::*;
    }

    /// Drizzle-owned wrapper for JSON column values.
    ///
    /// Not part of the dialect preludes, so it never collides with the
    /// `Json` SQL type marker in `drizzle::postgres::types` or
    /// `drizzle::mysql::types`; import it as `drizzle::core::Json`.
    #[cfg(feature = "serde")]
    #[doc(inline)]
    pub use drizzle_core::Json;

    /// The JSON column wrapper and the field conversions generated models use.
    #[cfg(feature = "serde")]
    pub mod json {
        #[doc(inline)]
        pub use drizzle_core::json::*;
    }

    /// Re-export serde for proc macro generated code.
    #[cfg(any(feature = "serde", feature = "query"))]
    #[doc(hidden)]
    pub use drizzle_core::serde;
    #[cfg(any(feature = "serde", feature = "query"))]
    #[doc(hidden)]
    pub use drizzle_core::serde_json;

    /// Row inference types and traits.
    #[doc(inline)]
    pub use drizzle_core::row::{
        AfterFullJoin, AfterJoin, AfterLeftJoin, AfterRightJoin, DecodeSelectedRef, ExprValueType,
        FromDrizzleRow, GroupByIdentity, HasSelectModel, IntoGroupBy, IntoSelectTarget,
        LeftLateralSelection, MarkerColumnCountValid, MarkerScopeValidFor, NullProbeRow, PkGroup,
        ResolveRow, RowColumnList, SQLTypeToRust, ScopePush, Scoped, SelectAs, SelectAsFrom,
        SelectCols, SelectExpr, SelectRequiredTables, SelectStar, WrapNullable,
    };
}

/// `SQLite` types, macros, and query builder.
#[cfg(feature = "sqlite")]
#[cfg_attr(docsrs, doc(cfg(feature = "sqlite")))]
pub mod sqlite {
    #[doc(inline)]
    pub use drizzle_macros::{
        SQLiteEnum, SQLiteFromRow, SQLiteIndex, SQLiteSchema, SQLiteTable, SQLiteView,
    };
    #[doc(inline)]
    pub use drizzle_sqlite::{
        SQLiteTransactionType, TransactionConfig, attrs, builder, common, connection, expr,
        helpers, pragma, traits, types, values,
    };

    #[cfg(feature = "rusqlite")]
    #[cfg_attr(docsrs, doc(cfg(feature = "rusqlite")))]
    pub mod rusqlite {
        #[doc(inline)]
        pub use crate::builder::sqlite::rusqlite::{Drizzle, DrizzleBuilder};
        #[doc(inline)]
        pub use crate::transaction::sqlite::rusqlite::Transaction;
        #[doc(hidden)]
        pub use ::rusqlite::{Error, Result, Row, types};
    }

    #[cfg(feature = "libsql")]
    #[cfg_attr(docsrs, doc(cfg(feature = "libsql")))]
    pub mod libsql {
        #[doc(inline)]
        pub use crate::builder::sqlite::libsql::{Drizzle, DrizzleBuilder};
        #[doc(inline)]
        pub use crate::transaction::sqlite::libsql::Transaction;
        #[doc(hidden)]
        pub use ::libsql::{Row, Value};
    }

    #[cfg(feature = "turso")]
    #[cfg_attr(docsrs, doc(cfg(feature = "turso")))]
    pub mod turso {
        #[doc(inline)]
        pub use crate::builder::sqlite::turso::{Drizzle, DrizzleBuilder};
        #[doc(inline)]
        pub use crate::transaction::sqlite::turso::Transaction;
        #[doc(hidden)]
        pub use ::turso::{Error, IntoValue, Result, Row, Value};
    }

    /// Cloudflare D1 driver (async, WASM-only).
    #[cfg(all(feature = "d1", target_arch = "wasm32"))]
    #[cfg_attr(docsrs, doc(cfg(all(feature = "d1", target_arch = "wasm32"))))]
    pub mod d1 {
        #[doc(inline)]
        pub use crate::builder::sqlite::d1::{Drizzle, DrizzleBuilder};
    }

    /// Cloudflare Durable Objects SQL storage driver (sync, WASM-only).
    #[cfg(all(feature = "durable", target_arch = "wasm32"))]
    #[cfg_attr(docsrs, doc(cfg(all(feature = "durable", target_arch = "wasm32"))))]
    pub mod durable {
        #[doc(inline)]
        pub use crate::builder::sqlite::durable::{Drizzle, DrizzleBuilder, DurableStorage};
        #[doc(inline)]
        pub use crate::transaction::sqlite::durable::Transaction;
    }

    /// `SQLite` prelude for schema declarations.
    pub mod prelude {
        // Core types and traits
        pub use crate::core::ToSQL;
        pub use crate::core::{Joinable, Relation, SchemaHasTable};
        pub use crate::core::{
            OrderBy, Param, ParamBind, ParamSet, Placeholder, SQL, SQLChunk, Token,
            TypedPlaceholder, asc, desc,
        };
        pub use crate::core::{OwnedPreparedStatement, PreparedStatement};
        pub use drizzle_core::tag;
        pub use drizzle_core::traits::*;
        // SQLite macros
        pub use drizzle_macros::{
            SQLiteEnum, SQLiteFromRow, SQLiteIndex, SQLiteSchema, SQLiteTable, SQLiteView,
        };
        // SQLite types
        pub use drizzle_sqlite::TransactionConfig;
        pub use drizzle_sqlite::attrs::*;
        pub use drizzle_sqlite::common::SQLiteSchemaType;
        pub use drizzle_sqlite::traits::{DrizzleSQLiteColumn, SQLiteColumn, SQLiteTable};
        pub use drizzle_sqlite::values::{
            OwnedSQLiteValue, SQLiteInsertValue, SQLiteUpdateValue, SQLiteValue, SQLiteValueRef,
        };
    }
}

/// `PostgreSQL` types, macros, and query builder.
#[cfg(feature = "postgres")]
#[cfg_attr(docsrs, doc(cfg(feature = "postgres")))]
pub mod postgres {
    #[doc(inline)]
    pub use drizzle_macros::{
        PostgresEnum, PostgresFromRow, PostgresIndex, PostgresPolicy, PostgresSchema,
        PostgresTable, PostgresView,
    };
    #[doc(hidden)]
    pub use drizzle_postgres::driver_types;
    #[doc(inline)]
    pub use drizzle_postgres::{
        AccessMode, IsolationLevel, TransactionConfig, attrs, builder, common, expr, helpers,
        traits, transaction, types, values,
    };

    #[cfg(all(
        feature = "postgres-sync",
        not(any(feature = "tokio-postgres", feature = "hyperdrive"))
    ))]
    #[doc(inline)]
    pub use drizzle_postgres::Row;
    #[cfg(any(feature = "tokio-postgres", feature = "hyperdrive"))]
    #[doc(inline)]
    pub use drizzle_postgres::Row;

    /// AWS Aurora Data API row + helpers (re-exported from drizzle-postgres).
    ///
    /// Required by the `#[PostgresTable]` macro when the `aws-data-api` feature
    /// is enabled — macro-generated code refers to
    /// `drizzle::postgres::aws_data_api::Row` and
    /// `drizzle::postgres::aws_data_api::is_null_at`.
    #[cfg(feature = "aws-data-api")]
    #[cfg_attr(docsrs, doc(cfg(feature = "aws-data-api")))]
    #[doc(inline)]
    pub use drizzle_postgres::aws_data_api;

    #[cfg(feature = "postgres-sync")]
    #[cfg_attr(docsrs, doc(cfg(feature = "postgres-sync")))]
    pub mod sync {
        #[doc(inline)]
        pub use crate::builder::postgres::postgres_sync::{Drizzle, DrizzleBuilder};
        #[doc(inline)]
        pub use crate::transaction::postgres::postgres_sync::Transaction;
    }

    /// Async `PostgreSQL` driver over [`tokio_postgres`].
    ///
    /// Enabled by either `tokio-postgres` (native) or `hyperdrive`
    /// (Cloudflare Workers) — both compile the same driver; only the way the
    /// connection is dialed differs. On wasm32 with the `hyperdrive` feature,
    /// `drizzle::postgres::hyperdrive` supplies the dial.
    #[cfg(any(feature = "tokio-postgres", feature = "hyperdrive"))]
    #[cfg_attr(
        docsrs,
        doc(cfg(any(feature = "tokio-postgres", feature = "hyperdrive")))
    )]
    pub mod tokio {
        #[doc(inline)]
        pub use crate::builder::postgres::tokio_postgres::{Drizzle, DrizzleBuilder};
        #[doc(inline)]
        pub use crate::transaction::postgres::tokio_postgres::Transaction;
    }

    /// Cloudflare Hyperdrive connector (WASM-only).
    ///
    /// Dials the [`tokio`](self::tokio) driver through a Workers `Hyperdrive`
    /// binding instead of a TCP socket. The resulting `Drizzle` is the exact
    /// type the native driver produces.
    #[cfg(all(feature = "hyperdrive", target_arch = "wasm32"))]
    #[cfg_attr(docsrs, doc(cfg(all(feature = "hyperdrive", target_arch = "wasm32"))))]
    pub mod hyperdrive {
        #[doc(inline)]
        pub use crate::builder::postgres::hyperdrive::{connect, connect_raw};
    }

    /// AWS Aurora Serverless Data API driver (HTTP-based, async).
    #[cfg(feature = "aws-data-api")]
    #[cfg_attr(docsrs, doc(cfg(feature = "aws-data-api")))]
    pub mod aws {
        #[doc(inline)]
        pub use crate::builder::postgres::aws_data_api::{Drizzle, DrizzleBuilder, Rows};
        #[doc(inline)]
        pub use crate::transaction::postgres::aws_data_api::{Transaction, TransactionBuilder};
    }

    /// `PostgreSQL` prelude for schema declarations.
    pub mod prelude {
        // Core types and traits
        pub use crate::core::ToSQL;
        pub use crate::core::{Joinable, Relation, SchemaHasTable};
        pub use crate::core::{
            OrderBy, Param, ParamBind, ParamSet, Placeholder, SQL, SQLChunk, Token,
            TypedPlaceholder, asc, desc,
        };
        pub use crate::core::{OwnedPreparedStatement, PreparedStatement};
        pub use drizzle_core::tag;
        pub use drizzle_core::traits::*;
        // PostgreSQL macros
        pub use drizzle_macros::{
            PostgresEnum, PostgresFromRow, PostgresIndex, PostgresPolicy, PostgresSchema,
            PostgresTable, PostgresView,
        };
        // PostgreSQL types
        pub use drizzle_postgres::attrs::*;
        pub use drizzle_postgres::common::PostgresSchemaType;
        pub use drizzle_postgres::traits::{DrizzlePostgresColumn, PostgresColumn, PostgresTable};
        pub use drizzle_postgres::values::{
            OwnedPostgresValue, PostgresInsertValue, PostgresUpdateValue, PostgresValue,
        };
        pub use drizzle_postgres::{AccessMode, IsolationLevel, TransactionConfig};
    }
}

/// `MySQL` dialect, query builders, values, and adapters.
///
/// ```
/// use drizzle::ddl::mysql::{MySQLType, MySQLTypeCategory};
/// use drizzle::mysql::{
///     MySQLDialect, MySQLMutationResult, MySQLValue, OwnedMySQLValue, TransactionConfig,
/// };
/// ```
///
/// First-class compatibility targets Oracle MySQL 8.0.31 and newer. MariaDB
/// and SingleStore are not part of this compatibility contract. The concrete
/// adapters inherit TLS configuration from the upstream `mysql` or
/// `mysql_async` resource supplied by the application.
///
/// Both adapters set each connection's session time zone to UTC and remove
/// `NO_UNSIGNED_SUBTRACTION` and `REAL_AS_FLOAT` before typed queries. This makes
/// temporal decoding and numeric types agree with the static Rust types.
///
/// MySQL upserts use `InsertBuilder::on_duplicate_key_update`. SQL `RETURNING`,
/// full joins, partial-index predicates, and PostgreSQL `UPDATE ... FROM` are
/// intentionally absent. Offset-only queries render MySQL's maximum-limit
/// sentinel, and typed string concatenation renders `CONCAT(...)`, never `||`.
///
/// ```compile_fail
/// use drizzle::mysql::builder::UpdateFromSet;
/// ```
#[cfg(feature = "mysql")]
#[cfg_attr(docsrs, doc(cfg(feature = "mysql")))]
pub mod mysql {
    #[doc(inline)]
    pub use drizzle_macros::{
        MySQLEnum, MySQLFromRow, MySQLIndex, MySQLSchema, MySQLTable, MySQLView,
    };
    #[doc(inline)]
    pub use drizzle_mysql::values::{MySQLValue, OwnedMySQLValue};
    #[doc(inline)]
    pub use drizzle_mysql::{
        AccessMode, IndexKeyPart, IndexOrder, IsolationLevel, MySQLDialect, MySQLMutationResult,
        ParamBind, TransactionConfig, ViewAlgorithm, ViewCheckOption, ViewSqlSecurity, attrs,
        builder, common, driver, helpers, index, traits, transaction, types, values,
    };

    /// Blocking adapter backed by the `mysql` crate.
    ///
    /// It owns the exact `mysql::Conn` or checked-out `mysql::PooledConn` passed
    /// to `Drizzle::new`; construction does not perform I/O. See
    /// [`Drizzle`](mysql_sync::Drizzle) for connection and transaction examples.
    #[cfg(feature = "mysql-sync")]
    #[cfg_attr(docsrs, doc(cfg(feature = "mysql-sync")))]
    pub mod mysql_sync {
        #[doc(inline)]
        pub use crate::builder::mysql::mysql_sync::{Drizzle, DrizzleBuilder, Rows, prepared};
        #[doc(inline)]
        pub use crate::transaction::mysql::mysql_sync::Transaction;
    }

    /// Async adapter backed by the `mysql_async` crate.
    ///
    /// It accepts an owned `mysql_async::Conn` or lazy `mysql_async::Pool`.
    /// Pool-backed operations check out a connection per operation; call
    /// [`Drizzle::disconnect`](mysql_async::Drizzle::disconnect) before the
    /// owning Tokio runtime stops.
    #[cfg(feature = "mysql-async")]
    #[cfg_attr(docsrs, doc(cfg(feature = "mysql-async")))]
    pub mod mysql_async {
        #[doc(inline)]
        pub use crate::builder::mysql::mysql_async::{Drizzle, DrizzleBuilder, Rows, prepared};
        #[doc(inline)]
        pub use crate::transaction::mysql::mysql_async::Transaction;
    }

    /// `MySQL` prelude for schema declarations.
    pub mod prelude {
        // Core types and traits
        pub use crate::core::ToSQL;
        pub use crate::core::{Joinable, Relation, SchemaHasTable};
        pub use crate::core::{
            OrderBy, Param, ParamBind, ParamSet, Placeholder, SQL, SQLChunk, Token,
            TypedPlaceholder,
        };
        pub use crate::core::{OwnedPreparedStatement, PreparedStatement};
        pub use drizzle_core::tag;
        pub use drizzle_core::traits::*;
        pub use drizzle_mysql::helpers::{MySQLIndexHintExt, asc, desc, output_alias};
        // MySQL macros
        pub use drizzle_macros::{
            MySQLEnum, MySQLFromRow, MySQLIndex, MySQLSchema, MySQLTable, MySQLView,
        };
        // MySQL types
        pub use drizzle_mysql::MySQLMutationResult;
        pub use drizzle_mysql::attrs::*;
        pub use drizzle_mysql::common::MySQLSchemaType;
        pub use drizzle_mysql::common::MySQLViewInfo;
        pub use drizzle_mysql::traits::{
            DrizzleMySQLColumn, MySQLColumn, MySQLEnum, MySQLIndexColumn, MySQLTable,
        };
        pub use drizzle_mysql::values::{
            MySQLInsertValue, MySQLUpdateValue, MySQLValue, OwnedMySQLValue,
        };
        pub use drizzle_mysql::{AccessMode, IsolationLevel, TransactionConfig};
        pub use drizzle_mysql::{
            IndexKeyPart, IndexOrder, MySQLIndexAlgorithm, MySQLIndexLock, MySQLIndexMetadata,
            MySQLIndexMethod,
        };
        pub use drizzle_mysql::{ViewAlgorithm, ViewCheckOption, ViewSqlSecurity};
    }
}

// =============================================================================
// Compile-fail tests (verified during `cargo test --doc`)
// =============================================================================

/// Type safety: abs() rejects non-numeric columns.
/// ```compile_fail,E0277
/// use drizzle::sqlite::prelude::*;
/// use drizzle::core::expr::abs;
///
/// #[SQLiteTable]
/// struct User {
///     #[column(primary)]
///     id: i32,
///     name: String,
/// }
///
/// fn main() {
///     let user = User::default();
///     let _ = abs(user.name);
/// }
/// ```
///
/// Type safety: avg() rejects non-numeric columns.
/// ```compile_fail,E0277
/// use drizzle::sqlite::prelude::*;
/// use drizzle::core::expr::avg;
///
/// #[SQLiteTable]
/// struct User {
///     #[column(primary)]
///     id: i32,
///     name: String,
/// }
///
/// fn main() {
///     let user = User::default();
///     let _ = avg(user.name);
/// }
/// ```
///
/// Type safety: sum() rejects non-numeric columns.
/// ```compile_fail,E0277
/// use drizzle::sqlite::prelude::*;
/// use drizzle::core::expr::sum;
///
/// #[SQLiteTable]
/// struct User {
///     #[column(primary)]
///     id: i32,
///     name: String,
/// }
///
/// fn main() {
///     let user = User::default();
///     let _ = sum(user.name);
/// }
/// ```
///
/// Type safety: Blob is not compatible with Integer.
/// ```compile_fail,E0277
/// use drizzle::sqlite::prelude::*;
/// use drizzle::core::expr::eq;
///
/// #[SQLiteTable]
/// struct Config {
///     #[column(primary)]
///     id: i32,
///     data: Vec<u8>,
/// }
///
/// fn main() {
///     let config = Config::default();
///     let _ = eq(config.data, 42);
/// }
/// ```
///
/// Type safety: Int is not compatible with Text.
/// ```compile_fail,E0277
/// use drizzle::sqlite::prelude::*;
/// use drizzle::core::expr::eq;
///
/// #[SQLiteTable]
/// struct User {
///     #[column(primary)]
///     id: i32,
///     name: String,
/// }
///
/// fn main() {
///     let user = User::default();
///     let _ = eq(user.id, "hello");
/// }
/// ```
///
/// Type safety: coalesce() rejects incompatible types.
/// ```compile_fail,E0277
/// use drizzle::sqlite::prelude::*;
/// use drizzle::core::expr::coalesce;
///
/// #[SQLiteTable]
/// struct User {
///     #[column(primary)]
///     id: i32,
///     name: String,
/// }
///
/// fn main() {
///     let user = User::default();
///     let _ = coalesce(user.id, "default");
/// }
/// ```
///
/// Type safety: concat() rejects non-textual columns.
/// ```compile_fail,E0277
/// use drizzle::sqlite::prelude::*;
/// use drizzle::core::expr::concat;
///
/// #[SQLiteTable]
/// struct User {
///     #[column(primary)]
///     id: i32,
///     name: String,
/// }
///
/// fn main() {
///     let user = User::default();
///     let _ = concat(user.id, user.name);
/// }
/// ```
///
/// Type safety: date() rejects non-temporal columns (Blob).
/// ```compile_fail,E0277
/// use drizzle::sqlite::prelude::*;
/// use drizzle::core::expr::date;
///
/// #[SQLiteTable]
/// struct Data {
///     #[column(primary)]
///     id: i32,
///     content: Vec<u8>,
/// }
///
/// fn main() {
///     let data = Data::default();
///     let _ = date(data.content);
/// }
/// ```
///
/// Type safety: like() rejects non-textual columns.
/// ```compile_fail,E0277
/// use drizzle::sqlite::prelude::*;
/// use drizzle::core::expr::like;
///
/// #[SQLiteTable]
/// struct User {
///     #[column(primary)]
///     id: i32,
///     name: String,
/// }
///
/// fn main() {
///     let user = User::default();
///     let _ = like(user.id, "%test%");
/// }
/// ```
///
/// Type safety: FK column type must match referenced column type.
/// ```compile_fail,E0277
/// use drizzle::sqlite::prelude::*;
///
/// #[SQLiteTable]
/// struct Parent {
///     #[column(primary)]
///     id: i32,
///     name: String,
/// }
///
/// #[SQLiteTable]
/// struct Child {
///     #[column(primary)]
///     id: i32,
///     #[column(references = Parent::id)]
///     parent_ref: String,
/// }
///
/// fn main() {}
/// ```
///
/// Type safety: FK target table must be in the schema.
/// ```compile_fail,E0277
/// use drizzle::sqlite::prelude::*;
///
/// #[SQLiteTable]
/// struct Parent {
///     #[column(primary)]
///     id: i32,
///     name: String,
/// }
///
/// #[SQLiteTable]
/// struct Child {
///     #[column(primary)]
///     id: i32,
///     #[column(references = Parent::id)]
///     parent_id: Option<i32>,
/// }
///
/// #[derive(SQLiteSchema)]
/// struct BadSchema {
///     child: Child,
/// }
///
/// fn main() {}
/// ```
///
/// Type safety: HasConstraint requires actual FK on the table.
/// ```compile_fail,E0277
/// use drizzle::sqlite::prelude::*;
///
/// #[SQLiteTable]
/// struct Simple {
///     #[column(primary)]
///     id: i32,
///     value: String,
/// }
///
/// fn requires_fk_constraint<T: HasConstraint<ForeignKeyK>>() {}
///
/// fn main() {
///     requires_fk_constraint::<Simple>();
/// }
/// ```
///
/// Type safety: Relation requires a FK between the tables.
/// ```compile_fail,E0277
/// use drizzle::sqlite::prelude::*;
///
/// #[SQLiteTable]
/// struct Parent {
///     #[column(primary)]
///     id: i32,
///     name: String,
/// }
///
/// #[SQLiteTable]
/// struct Simple {
///     #[column(primary)]
///     id: i32,
///     value: String,
/// }
///
/// fn requires_relation<T: Relation<Parent>>() {}
///
/// fn main() {
///     requires_relation::<Simple>();
/// }
/// ```
///
/// Type safety: Joinable requires a FK relationship.
/// ```compile_fail,E0277
/// use drizzle::sqlite::prelude::*;
///
/// #[SQLiteTable]
/// struct Parent {
///     #[column(primary)]
///     id: i32,
///     name: String,
/// }
///
/// #[SQLiteTable]
/// struct Unrelated {
///     #[column(primary)]
///     id: i32,
///     value: String,
/// }
///
/// fn requires_joinable<A: Joinable<B>, B>() {}
///
/// fn main() {
///     requires_joinable::<Unrelated, Parent>();
/// }
/// ```
#[cfg(doctest)]
struct _CompileFailTests;