prax-codegen 0.9.4

Procedural macros for code generation in the Prax ORM
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
//! Type mapping from Prax schema types to Rust types.

use convert_case::{Case, Casing};
use proc_macro2::TokenStream;
use quote::{format_ident, quote};

use prax_schema::ast::{FieldType, ScalarType, TypeModifier};

/// Convert a schema scalar type to its Rust type token stream.
pub fn scalar_to_rust_type(scalar: &ScalarType) -> TokenStream {
    match scalar {
        ScalarType::Int => quote! { i32 },
        ScalarType::BigInt => quote! { i64 },
        ScalarType::Float => quote! { f64 },
        ScalarType::Decimal => quote! { rust_decimal::Decimal },
        ScalarType::Boolean => quote! { bool },
        ScalarType::String => quote! { String },
        ScalarType::DateTime => quote! { chrono::DateTime<chrono::Utc> },
        ScalarType::Date => quote! { chrono::NaiveDate },
        ScalarType::Time => quote! { chrono::NaiveTime },
        ScalarType::Json => quote! { serde_json::Value },
        ScalarType::Bytes => quote! { Vec<u8> },
        ScalarType::Uuid => quote! { uuid::Uuid },
        // String-based ID types (stored as String in Rust)
        ScalarType::Cuid | ScalarType::Cuid2 | ScalarType::NanoId | ScalarType::Ulid => {
            quote! { String }
        }
        // PostgreSQL vector types (require pgvector crate)
        ScalarType::Vector(_) | ScalarType::HalfVector(_) => quote! { Vec<f32> },
        ScalarType::SparseVector(_) => quote! { Vec<(u32, f32)> },
        ScalarType::Bit(_) => quote! { Vec<u8> },
    }
}

/// Convert a field type to its Rust type token stream.
pub fn field_type_to_rust(field_type: &FieldType, modifier: &TypeModifier) -> TokenStream {
    let base_type = match field_type {
        FieldType::Scalar(scalar) => scalar_to_rust_type(scalar),
        FieldType::Enum(name) | FieldType::Model(name) | FieldType::Composite(name) => {
            let ident = format_ident!("{}", name.to_string());
            quote! { #ident }
        }
        FieldType::Unsupported(raw) => {
            // For unsupported types, we use a raw SQL type wrapper
            let raw_str = raw.as_str();
            quote! { prax::types::UnsupportedType<#raw_str> }
        }
    };

    apply_modifier(base_type, modifier)
}

/// Apply a type modifier to a base type.
pub fn apply_modifier(base_type: TokenStream, modifier: &TypeModifier) -> TokenStream {
    match modifier {
        TypeModifier::Required => base_type,
        TypeModifier::Optional => quote! { Option<#base_type> },
        TypeModifier::List => quote! { Vec<#base_type> },
        TypeModifier::OptionalList => quote! { Option<Vec<#base_type>> },
    }
}

/// Convert a field type to the SQL type string for the query builder.
#[allow(dead_code)]
pub fn field_type_to_sql_type(field_type: &FieldType) -> &'static str {
    match field_type {
        FieldType::Scalar(scalar) => match scalar {
            ScalarType::Int => "INT",
            ScalarType::BigInt => "BIGINT",
            ScalarType::Float => "DOUBLE PRECISION",
            ScalarType::Decimal => "DECIMAL",
            ScalarType::Boolean => "BOOLEAN",
            ScalarType::String => "TEXT",
            ScalarType::DateTime => "TIMESTAMPTZ",
            ScalarType::Date => "DATE",
            ScalarType::Time => "TIME",
            ScalarType::Json => "JSONB",
            ScalarType::Bytes => "BYTEA",
            ScalarType::Uuid => "UUID",
            // String-based ID types (stored as TEXT/VARCHAR in database)
            ScalarType::Cuid | ScalarType::Cuid2 | ScalarType::NanoId | ScalarType::Ulid => "TEXT",
            // PostgreSQL vector extension types (dimension is handled separately)
            ScalarType::Vector(_) => "vector",
            ScalarType::HalfVector(_) => "halfvec",
            ScalarType::SparseVector(_) => "sparsevec",
            ScalarType::Bit(_) => "bit",
        },
        FieldType::Enum(_) => "TEXT",       // Enums are stored as text
        FieldType::Model(_) => "INT",       // Foreign key reference
        FieldType::Composite(_) => "JSONB", // Composite types as JSON
        FieldType::Unsupported(_raw) => {
            // Return the raw type as-is (static lifetime requires leaking)
            // In practice, we should handle this differently
            "UNKNOWN"
        }
    }
}

/// Convert a name to snake_case for module/function names.
pub fn to_snake_case(name: &str) -> String {
    name.to_case(Case::Snake)
}

/// Convert a name to PascalCase for type names.
pub fn to_pascal_case(name: &str) -> String {
    name.to_case(Case::Pascal)
}

/// Convert a name to SCREAMING_SNAKE_CASE for constants.
#[allow(dead_code)]
pub fn to_screaming_snake(name: &str) -> String {
    name.to_case(Case::ScreamingSnake)
}

/// Get the default value expression for a scalar type.
#[allow(dead_code)]
pub fn default_value_for_type(scalar: &ScalarType) -> TokenStream {
    match scalar {
        ScalarType::Int | ScalarType::BigInt => quote! { 0 },
        ScalarType::Float | ScalarType::Decimal => quote! { 0.0 },
        ScalarType::Boolean => quote! { false },
        ScalarType::String => quote! { String::new() },
        ScalarType::DateTime => quote! { chrono::Utc::now() },
        ScalarType::Date => quote! { chrono::Utc::now().date_naive() },
        ScalarType::Time => quote! { chrono::Utc::now().time() },
        ScalarType::Json => quote! { serde_json::Value::Null },
        ScalarType::Bytes => quote! { Vec::new() },
        ScalarType::Uuid => quote! { uuid::Uuid::nil() },
        // String-based ID types default to empty string
        ScalarType::Cuid | ScalarType::Cuid2 | ScalarType::NanoId | ScalarType::Ulid => {
            quote! { String::new() }
        }
        // Vector types default to empty vector
        ScalarType::Vector(_) | ScalarType::HalfVector(_) => quote! { Vec::new() },
        ScalarType::SparseVector(_) => quote! { Vec::new() },
        ScalarType::Bit(_) => quote! { Vec::new() },
    }
}

/// Check if a scalar type supports comparison operations (>, <, >=, <=).
pub fn supports_comparison(scalar: &ScalarType) -> bool {
    matches!(
        scalar,
        ScalarType::Int
            | ScalarType::BigInt
            | ScalarType::Float
            | ScalarType::Decimal
            | ScalarType::DateTime
            | ScalarType::Date
            | ScalarType::Time
    )
}

/// Check if a scalar type supports string operations (contains, startsWith, etc.).
pub fn supports_string_ops(scalar: &ScalarType) -> bool {
    matches!(scalar, ScalarType::String)
}

/// Check if a type supports the `in` operation.
pub fn supports_in_op(field_type: &FieldType) -> bool {
    match field_type {
        FieldType::Scalar(scalar) => !matches!(scalar, ScalarType::Json | ScalarType::Bytes),
        FieldType::Enum(_) => true,
        _ => false,
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use smol_str::SmolStr;

    #[test]
    fn test_scalar_to_rust_type() {
        assert_eq!(scalar_to_rust_type(&ScalarType::Int).to_string(), "i32");
        assert_eq!(scalar_to_rust_type(&ScalarType::BigInt).to_string(), "i64");
        assert_eq!(scalar_to_rust_type(&ScalarType::Float).to_string(), "f64");
        assert_eq!(
            scalar_to_rust_type(&ScalarType::Boolean).to_string(),
            "bool"
        );
        assert_eq!(
            scalar_to_rust_type(&ScalarType::String).to_string(),
            "String"
        );
    }

    #[test]
    fn test_scalar_to_rust_type_all_scalars() {
        // Test all scalar types for comprehensive coverage
        assert_eq!(scalar_to_rust_type(&ScalarType::Int).to_string(), "i32");
        assert_eq!(scalar_to_rust_type(&ScalarType::BigInt).to_string(), "i64");
        assert_eq!(scalar_to_rust_type(&ScalarType::Float).to_string(), "f64");
        assert!(
            scalar_to_rust_type(&ScalarType::Decimal)
                .to_string()
                .contains("Decimal")
        );
        assert_eq!(
            scalar_to_rust_type(&ScalarType::Boolean).to_string(),
            "bool"
        );
        assert_eq!(
            scalar_to_rust_type(&ScalarType::String).to_string(),
            "String"
        );
        assert!(
            scalar_to_rust_type(&ScalarType::DateTime)
                .to_string()
                .contains("DateTime")
        );
        assert!(
            scalar_to_rust_type(&ScalarType::Date)
                .to_string()
                .contains("NaiveDate")
        );
        assert!(
            scalar_to_rust_type(&ScalarType::Time)
                .to_string()
                .contains("NaiveTime")
        );
        assert!(
            scalar_to_rust_type(&ScalarType::Json)
                .to_string()
                .contains("Value")
        );
        assert!(
            scalar_to_rust_type(&ScalarType::Bytes)
                .to_string()
                .contains("Vec")
        );
        assert!(
            scalar_to_rust_type(&ScalarType::Uuid)
                .to_string()
                .contains("Uuid")
        );

        // String-based ID types
        assert_eq!(scalar_to_rust_type(&ScalarType::Cuid).to_string(), "String");
        assert_eq!(
            scalar_to_rust_type(&ScalarType::Cuid2).to_string(),
            "String"
        );
        assert_eq!(
            scalar_to_rust_type(&ScalarType::NanoId).to_string(),
            "String"
        );
        assert_eq!(scalar_to_rust_type(&ScalarType::Ulid).to_string(), "String");
    }

    #[test]
    fn test_field_type_to_rust_scalar() {
        let field_type = FieldType::Scalar(ScalarType::Int);
        let result = field_type_to_rust(&field_type, &TypeModifier::Required);
        assert_eq!(result.to_string(), "i32");
    }

    #[test]
    fn test_field_type_to_rust_enum() {
        let field_type = FieldType::Enum(SmolStr::new("UserRole"));
        let result = field_type_to_rust(&field_type, &TypeModifier::Required);
        assert!(result.to_string().contains("UserRole"));
    }

    #[test]
    fn test_field_type_to_rust_model() {
        let field_type = FieldType::Model(SmolStr::new("User"));
        let result = field_type_to_rust(&field_type, &TypeModifier::Required);
        assert!(result.to_string().contains("User"));
    }

    #[test]
    fn test_field_type_to_rust_composite() {
        let field_type = FieldType::Composite(SmolStr::new("Address"));
        let result = field_type_to_rust(&field_type, &TypeModifier::Required);
        assert!(result.to_string().contains("Address"));
    }

    #[test]
    fn test_field_type_to_rust_unsupported() {
        let field_type = FieldType::Unsupported(SmolStr::new("GEOGRAPHY"));
        let result = field_type_to_rust(&field_type, &TypeModifier::Required);
        assert!(result.to_string().contains("UnsupportedType"));
        assert!(result.to_string().contains("GEOGRAPHY"));
    }

    #[test]
    fn test_field_type_to_rust_with_modifiers() {
        let field_type = FieldType::Scalar(ScalarType::String);

        // Required
        let required = field_type_to_rust(&field_type, &TypeModifier::Required);
        assert_eq!(required.to_string(), "String");

        // Optional
        let optional = field_type_to_rust(&field_type, &TypeModifier::Optional);
        assert!(optional.to_string().contains("Option"));

        // List
        let list = field_type_to_rust(&field_type, &TypeModifier::List);
        assert!(list.to_string().contains("Vec"));

        // Optional List
        let opt_list = field_type_to_rust(&field_type, &TypeModifier::OptionalList);
        assert!(opt_list.to_string().contains("Option"));
        assert!(opt_list.to_string().contains("Vec"));
    }

    #[test]
    fn test_apply_modifier() {
        let base = quote! { i32 };

        let required = apply_modifier(base.clone(), &TypeModifier::Required);
        assert_eq!(required.to_string(), "i32");

        let optional = apply_modifier(base.clone(), &TypeModifier::Optional);
        assert_eq!(optional.to_string(), "Option < i32 >");

        let list = apply_modifier(base.clone(), &TypeModifier::List);
        assert_eq!(list.to_string(), "Vec < i32 >");

        let opt_list = apply_modifier(base, &TypeModifier::OptionalList);
        assert_eq!(opt_list.to_string(), "Option < Vec < i32 >>");
    }

    #[test]
    fn test_field_type_to_sql_type_scalars() {
        assert_eq!(
            field_type_to_sql_type(&FieldType::Scalar(ScalarType::Int)),
            "INT"
        );
        assert_eq!(
            field_type_to_sql_type(&FieldType::Scalar(ScalarType::BigInt)),
            "BIGINT"
        );
        assert_eq!(
            field_type_to_sql_type(&FieldType::Scalar(ScalarType::Float)),
            "DOUBLE PRECISION"
        );
        assert_eq!(
            field_type_to_sql_type(&FieldType::Scalar(ScalarType::Decimal)),
            "DECIMAL"
        );
        assert_eq!(
            field_type_to_sql_type(&FieldType::Scalar(ScalarType::Boolean)),
            "BOOLEAN"
        );
        assert_eq!(
            field_type_to_sql_type(&FieldType::Scalar(ScalarType::String)),
            "TEXT"
        );
        assert_eq!(
            field_type_to_sql_type(&FieldType::Scalar(ScalarType::DateTime)),
            "TIMESTAMPTZ"
        );
        assert_eq!(
            field_type_to_sql_type(&FieldType::Scalar(ScalarType::Date)),
            "DATE"
        );
        assert_eq!(
            field_type_to_sql_type(&FieldType::Scalar(ScalarType::Time)),
            "TIME"
        );
        assert_eq!(
            field_type_to_sql_type(&FieldType::Scalar(ScalarType::Json)),
            "JSONB"
        );
        assert_eq!(
            field_type_to_sql_type(&FieldType::Scalar(ScalarType::Bytes)),
            "BYTEA"
        );
        assert_eq!(
            field_type_to_sql_type(&FieldType::Scalar(ScalarType::Uuid)),
            "UUID"
        );
        // String-based ID types
        assert_eq!(
            field_type_to_sql_type(&FieldType::Scalar(ScalarType::Cuid)),
            "TEXT"
        );
        assert_eq!(
            field_type_to_sql_type(&FieldType::Scalar(ScalarType::Cuid2)),
            "TEXT"
        );
        assert_eq!(
            field_type_to_sql_type(&FieldType::Scalar(ScalarType::NanoId)),
            "TEXT"
        );
        assert_eq!(
            field_type_to_sql_type(&FieldType::Scalar(ScalarType::Ulid)),
            "TEXT"
        );
    }

    #[test]
    fn test_field_type_to_sql_type_complex() {
        assert_eq!(
            field_type_to_sql_type(&FieldType::Enum(SmolStr::new("Role"))),
            "TEXT"
        );
        assert_eq!(
            field_type_to_sql_type(&FieldType::Model(SmolStr::new("User"))),
            "INT"
        );
        assert_eq!(
            field_type_to_sql_type(&FieldType::Composite(SmolStr::new("Address"))),
            "JSONB"
        );
        assert_eq!(
            field_type_to_sql_type(&FieldType::Unsupported(SmolStr::new("CUSTOM_TYPE"))),
            "UNKNOWN"
        );
    }

    #[test]
    fn test_case_conversion() {
        assert_eq!(to_snake_case("UserProfile"), "user_profile");
        assert_eq!(to_pascal_case("user_profile"), "UserProfile");
        assert_eq!(to_screaming_snake("UserProfile"), "USER_PROFILE");
    }

    #[test]
    fn test_case_conversion_edge_cases() {
        // Single word
        assert_eq!(to_snake_case("User"), "user");
        assert_eq!(to_pascal_case("user"), "User");
        assert_eq!(to_screaming_snake("user"), "USER");

        // Multiple words
        assert_eq!(to_snake_case("HTTPRequest"), "http_request");
        assert_eq!(to_pascal_case("http_request"), "HttpRequest");
        assert_eq!(to_screaming_snake("HttpRequest"), "HTTP_REQUEST");

        // Already correct case
        assert_eq!(to_snake_case("already_snake"), "already_snake");
        assert_eq!(to_pascal_case("AlreadyPascal"), "AlreadyPascal");
    }

    #[test]
    fn test_default_value_for_type() {
        // Numeric types
        let int_default = default_value_for_type(&ScalarType::Int);
        assert_eq!(int_default.to_string(), "0");

        let bigint_default = default_value_for_type(&ScalarType::BigInt);
        assert_eq!(bigint_default.to_string(), "0");

        let float_default = default_value_for_type(&ScalarType::Float);
        assert_eq!(float_default.to_string(), "0.0");

        let decimal_default = default_value_for_type(&ScalarType::Decimal);
        assert_eq!(decimal_default.to_string(), "0.0");

        // Boolean
        let bool_default = default_value_for_type(&ScalarType::Boolean);
        assert_eq!(bool_default.to_string(), "false");

        // String
        let string_default = default_value_for_type(&ScalarType::String);
        assert!(string_default.to_string().contains("String :: new"));

        // DateTime types
        let datetime_default = default_value_for_type(&ScalarType::DateTime);
        assert!(datetime_default.to_string().contains("Utc :: now"));

        let date_default = default_value_for_type(&ScalarType::Date);
        assert!(date_default.to_string().contains("date_naive"));

        let time_default = default_value_for_type(&ScalarType::Time);
        assert!(time_default.to_string().contains("time"));

        // Json
        let json_default = default_value_for_type(&ScalarType::Json);
        assert!(json_default.to_string().contains("Null"));

        // Bytes
        let bytes_default = default_value_for_type(&ScalarType::Bytes);
        assert!(bytes_default.to_string().contains("Vec :: new"));

        // Uuid
        let uuid_default = default_value_for_type(&ScalarType::Uuid);
        assert!(uuid_default.to_string().contains("nil"));

        // String-based ID types
        let cuid_default = default_value_for_type(&ScalarType::Cuid);
        assert!(cuid_default.to_string().contains("String :: new"));

        let cuid2_default = default_value_for_type(&ScalarType::Cuid2);
        assert!(cuid2_default.to_string().contains("String :: new"));

        let nanoid_default = default_value_for_type(&ScalarType::NanoId);
        assert!(nanoid_default.to_string().contains("String :: new"));

        let ulid_default = default_value_for_type(&ScalarType::Ulid);
        assert!(ulid_default.to_string().contains("String :: new"));
    }

    #[test]
    fn test_supports_comparison() {
        assert!(supports_comparison(&ScalarType::Int));
        assert!(supports_comparison(&ScalarType::DateTime));
        assert!(!supports_comparison(&ScalarType::String));
        assert!(!supports_comparison(&ScalarType::Boolean));
    }

    #[test]
    fn test_supports_comparison_all_types() {
        // Comparison supported
        assert!(supports_comparison(&ScalarType::Int));
        assert!(supports_comparison(&ScalarType::BigInt));
        assert!(supports_comparison(&ScalarType::Float));
        assert!(supports_comparison(&ScalarType::Decimal));
        assert!(supports_comparison(&ScalarType::DateTime));
        assert!(supports_comparison(&ScalarType::Date));
        assert!(supports_comparison(&ScalarType::Time));

        // Comparison not supported
        assert!(!supports_comparison(&ScalarType::String));
        assert!(!supports_comparison(&ScalarType::Boolean));
        assert!(!supports_comparison(&ScalarType::Json));
        assert!(!supports_comparison(&ScalarType::Bytes));
        assert!(!supports_comparison(&ScalarType::Uuid));
        assert!(!supports_comparison(&ScalarType::Cuid));
        assert!(!supports_comparison(&ScalarType::Cuid2));
        assert!(!supports_comparison(&ScalarType::NanoId));
        assert!(!supports_comparison(&ScalarType::Ulid));
    }

    #[test]
    fn test_supports_string_ops() {
        assert!(supports_string_ops(&ScalarType::String));
        assert!(!supports_string_ops(&ScalarType::Int));
    }

    #[test]
    fn test_supports_string_ops_all_types() {
        // String ops supported
        assert!(supports_string_ops(&ScalarType::String));

        // String ops not supported
        assert!(!supports_string_ops(&ScalarType::Int));
        assert!(!supports_string_ops(&ScalarType::BigInt));
        assert!(!supports_string_ops(&ScalarType::Float));
        assert!(!supports_string_ops(&ScalarType::Decimal));
        assert!(!supports_string_ops(&ScalarType::Boolean));
        assert!(!supports_string_ops(&ScalarType::DateTime));
        assert!(!supports_string_ops(&ScalarType::Date));
        assert!(!supports_string_ops(&ScalarType::Time));
        assert!(!supports_string_ops(&ScalarType::Json));
        assert!(!supports_string_ops(&ScalarType::Bytes));
        assert!(!supports_string_ops(&ScalarType::Uuid));
        assert!(!supports_string_ops(&ScalarType::Cuid));
    }

    #[test]
    fn test_supports_in_op() {
        // Scalars that support IN
        assert!(supports_in_op(&FieldType::Scalar(ScalarType::Int)));
        assert!(supports_in_op(&FieldType::Scalar(ScalarType::BigInt)));
        assert!(supports_in_op(&FieldType::Scalar(ScalarType::Float)));
        assert!(supports_in_op(&FieldType::Scalar(ScalarType::Decimal)));
        assert!(supports_in_op(&FieldType::Scalar(ScalarType::Boolean)));
        assert!(supports_in_op(&FieldType::Scalar(ScalarType::String)));
        assert!(supports_in_op(&FieldType::Scalar(ScalarType::DateTime)));
        assert!(supports_in_op(&FieldType::Scalar(ScalarType::Date)));
        assert!(supports_in_op(&FieldType::Scalar(ScalarType::Time)));
        assert!(supports_in_op(&FieldType::Scalar(ScalarType::Uuid)));
        assert!(supports_in_op(&FieldType::Scalar(ScalarType::Cuid)));

        // Scalars that don't support IN
        assert!(!supports_in_op(&FieldType::Scalar(ScalarType::Json)));
        assert!(!supports_in_op(&FieldType::Scalar(ScalarType::Bytes)));

        // Enum supports IN
        assert!(supports_in_op(&FieldType::Enum(SmolStr::new("Role"))));

        // Model and Composite don't support IN
        assert!(!supports_in_op(&FieldType::Model(SmolStr::new("User"))));
        assert!(!supports_in_op(&FieldType::Composite(SmolStr::new(
            "Address"
        ))));
        assert!(!supports_in_op(&FieldType::Unsupported(SmolStr::new(
            "CUSTOM"
        ))));
    }
}