mool 0.2.0

A source-first Rust database toolkit for typed SQL queries, migrations, and model metadata
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
use super::*;

/// Verifies placeholder parsing and resolution for `empty string`.
#[test]
fn empty_string() {
    assert_eq!(collect_parts(""), vec![]);
}

/// Verifies placeholder parsing and resolution for `no placeholders`.
#[test]
fn no_placeholders() {
    let parts = collect_parts("SELECT * FROM users");
    assert_eq!(parts, vec![PlaceholderPart::Sql("SELECT * FROM users")]);
}

/// Verifies placeholder parsing and resolution for `single placeholder`.
#[test]
fn single_placeholder() {
    let parts = collect_parts("SELECT * FROM users WHERE id = :id");
    assert_eq!(
        parts,
        vec![
            PlaceholderPart::Sql("SELECT * FROM users WHERE id = "),
            PlaceholderPart::Placeholder("id"),
        ]
    );
}

/// Verifies placeholder parsing and resolution for `multiple placeholders`.
#[test]
fn multiple_placeholders() {
    let parts = collect_parts("SELECT * FROM users WHERE id = :id AND name = :name");
    assert_eq!(
        parts,
        vec![
            PlaceholderPart::Sql("SELECT * FROM users WHERE id = "),
            PlaceholderPart::Placeholder("id"),
            PlaceholderPart::Sql(" AND name = "),
            PlaceholderPart::Placeholder("name"),
        ]
    );
}

/// Verifies placeholder parsing and resolution for `placeholder at start`.
#[test]
fn placeholder_at_start() {
    let parts = collect_parts(":id");
    assert_eq!(parts, vec![PlaceholderPart::Placeholder("id"),]);
}

/// Verifies placeholder parsing and resolution for `placeholder at end`.
#[test]
fn placeholder_at_end() {
    let parts = collect_parts("SELECT :id");
    assert_eq!(
        parts,
        vec![
            PlaceholderPart::Sql("SELECT "),
            PlaceholderPart::Placeholder("id"),
        ]
    );
}

/// Verifies placeholder parsing and resolution for `placeholder names with numbers and underscores`.
#[test]
fn placeholder_names_with_numbers_and_underscores() {
    let parts = collect_parts(":id_1 :user2 :_private");
    assert_eq!(
        parts,
        vec![
            PlaceholderPart::Placeholder("id_1"),
            PlaceholderPart::Sql(" "),
            PlaceholderPart::Placeholder("user2"),
            PlaceholderPart::Sql(" "),
            PlaceholderPart::Placeholder("_private"),
        ]
    );
}

/// Verifies placeholder parsing and resolution for `double colon not placeholder`.
#[test]
fn double_colon_not_placeholder() {
    // PostgreSQL cast operator ::
    let parts = collect_parts("SELECT id::integer");
    assert_eq!(parts, vec![PlaceholderPart::Sql("SELECT id::integer")]);
}

/// Verifies placeholder parsing and resolution for `colon at end of string`.
#[test]
fn colon_at_end_of_string() {
    let parts = collect_parts("SELECT :");
    assert_eq!(parts, vec![PlaceholderPart::Sql("SELECT :")]);
}

/// Verifies placeholder parsing and resolution for `colon followed by non name`.
#[test]
fn colon_followed_by_non_name() {
    let parts = collect_parts("SELECT :123");
    assert_eq!(parts, vec![PlaceholderPart::Sql("SELECT :123")]);
}

/// Verifies placeholder parsing and resolution for `word char before colon not placeholder`.
#[test]
fn word_char_before_colon_not_placeholder() {
    let parts = collect_parts("abc:param");
    assert_eq!(parts, vec![PlaceholderPart::Sql("abc:param")]);
}

/// Verifies placeholder parsing and resolution for `placeholder in single quotes ignored`.
#[test]
fn placeholder_in_single_quotes_ignored() {
    let parts = collect_parts("SELECT 'text :param' FROM t");
    assert_eq!(
        parts,
        vec![PlaceholderPart::Sql("SELECT 'text :param' FROM t")]
    );
}

/// Verifies placeholder parsing and resolution for `placeholder in double quotes ignored`.
#[test]
fn placeholder_in_double_quotes_ignored() {
    let parts = collect_parts("SELECT \"col:param\" FROM t");
    assert_eq!(
        parts,
        vec![PlaceholderPart::Sql("SELECT \"col:param\" FROM t")]
    );
}

/// Verifies placeholder parsing and resolution for `placeholder in backticks ignored`.
#[test]
fn placeholder_in_backticks_ignored() {
    let parts = collect_parts("SELECT `col:param` FROM t");
    assert_eq!(
        parts,
        vec![PlaceholderPart::Sql("SELECT `col:param` FROM t")]
    );
}

/// Verifies placeholder parsing and resolution for `placeholder in bracket ident ignored`.
#[test]
fn placeholder_in_bracket_ident_ignored() {
    let parts = collect_parts("SELECT [col:param] FROM t");
    assert_eq!(
        parts,
        vec![PlaceholderPart::Sql("SELECT [col:param] FROM t")]
    );
}

/// Verifies placeholder parsing and resolution for `escaped single quote with doubling`.
#[test]
fn escaped_single_quote_with_doubling() {
    let parts = collect_parts("SELECT 'don''t :param' FROM t");
    assert_eq!(
        parts,
        vec![PlaceholderPart::Sql("SELECT 'don''t :param' FROM t")]
    );
}

/// Verifies placeholder parsing and resolution for `escaped double quote with doubling`.
#[test]
fn escaped_double_quote_with_doubling() {
    let parts = collect_parts("SELECT \"col\"\"name:param\" FROM t");
    assert_eq!(
        parts,
        vec![PlaceholderPart::Sql("SELECT \"col\"\"name:param\" FROM t")]
    );
}

/// Verifies placeholder parsing and resolution for `escaped backtick with doubling`.
#[test]
fn escaped_backtick_with_doubling() {
    let parts = collect_parts("SELECT `col``name:param` FROM t");
    assert_eq!(
        parts,
        vec![PlaceholderPart::Sql("SELECT `col``name:param` FROM t")]
    );
}

/// Verifies placeholder parsing and resolution for `backslash escape single quote`.
#[test]
fn backslash_escape_single_quote() {
    let parts = collect_parts("SELECT 'don\\'t :param' FROM t");
    assert_eq!(
        parts,
        vec![PlaceholderPart::Sql("SELECT 'don\\'t :param' FROM t")]
    );
}

/// Verifies placeholder parsing and resolution for `backslash escape double quote`.
#[test]
fn backslash_escape_double_quote() {
    let parts = collect_parts("SELECT \"col\\\"name:param\" FROM t");
    assert_eq!(
        parts,
        vec![PlaceholderPart::Sql("SELECT \"col\\\"name:param\" FROM t")]
    );
}

/// Verifies placeholder parsing and resolution for `backslash escape backtick`.
#[test]
fn backslash_escape_backtick() {
    let parts = collect_parts("SELECT `col\\`name:param` FROM t");
    assert_eq!(
        parts,
        vec![PlaceholderPart::Sql("SELECT `col\\`name:param` FROM t")]
    );
}

/// Verifies placeholder parsing and resolution for `backslash at end of single quote`.
#[test]
fn backslash_at_end_of_single_quote() {
    // 'text\' - the backslash escapes the closing quote, so string is unclosed
    let parts = collect_parts("SELECT 'text\\' :param");
    assert_eq!(parts, vec![PlaceholderPart::Sql("SELECT 'text\\' :param")]);
}

/// Verifies placeholder parsing and resolution for `backslash backslash in quote`.
#[test]
fn backslash_backslash_in_quote() {
    let parts = collect_parts("SELECT 'path\\\\:param' FROM t");
    assert_eq!(
        parts,
        vec![PlaceholderPart::Sql("SELECT 'path\\\\:param' FROM t")]
    );
}

/// Verifies placeholder parsing and resolution for `line comment double dash`.
#[test]
fn line_comment_double_dash() {
    let parts = collect_parts("SELECT * -- :param\nFROM t");
    assert_eq!(
        parts,
        vec![PlaceholderPart::Sql("SELECT * -- :param\nFROM t")]
    );
}

/// Verifies placeholder parsing and resolution for `line comment hash`.
#[test]
fn line_comment_hash() {
    let parts = collect_parts("SELECT * # :param\nFROM t");
    assert_eq!(
        parts,
        vec![PlaceholderPart::Sql("SELECT * # :param\nFROM t")]
    );
}

/// Verifies placeholder parsing and resolution for `line comment at end no newline`.
#[test]
fn line_comment_at_end_no_newline() {
    let parts = collect_parts("SELECT * -- :param");
    assert_eq!(parts, vec![PlaceholderPart::Sql("SELECT * -- :param")]);
}

/// Verifies placeholder parsing and resolution for `block comment`.
#[test]
fn block_comment() {
    let parts = collect_parts("SELECT * /* :param */ FROM t");
    assert_eq!(
        parts,
        vec![PlaceholderPart::Sql("SELECT * /* :param */ FROM t")]
    );
}

/// Verifies placeholder parsing and resolution for `block comment multiline`.
#[test]
fn block_comment_multiline() {
    let parts = collect_parts("SELECT * /* line1\n:param\nline2 */ FROM t");
    assert_eq!(
        parts,
        vec![PlaceholderPart::Sql(
            "SELECT * /* line1\n:param\nline2 */ FROM t"
        )]
    );
}

/// Verifies placeholder parsing and resolution for `block comment not closed`.
#[test]
fn block_comment_not_closed() {
    let parts = collect_parts("SELECT * /* :param");
    assert_eq!(parts, vec![PlaceholderPart::Sql("SELECT * /* :param")]);
}

/// Verifies placeholder parsing and resolution for `dollar quote empty tag`.
#[test]
fn dollar_quote_empty_tag() {
    let parts = collect_parts("SELECT $$:param$$ FROM t");
    assert_eq!(
        parts,
        vec![PlaceholderPart::Sql("SELECT $$:param$$ FROM t")]
    );
}

/// Verifies placeholder parsing and resolution for `dollar quote with tag`.
#[test]
fn dollar_quote_with_tag() {
    let parts = collect_parts("SELECT $tag$:param$tag$ FROM t");
    assert_eq!(
        parts,
        vec![PlaceholderPart::Sql("SELECT $tag$:param$tag$ FROM t")]
    );
}

/// Verifies placeholder parsing and resolution for `dollar quote different tags not matched`.
#[test]
fn dollar_quote_different_tags_not_matched() {
    let parts = collect_parts("SELECT $a$text$b$ FROM t");
    assert_eq!(
        parts,
        vec![PlaceholderPart::Sql("SELECT $a$text$b$ FROM t")]
    );
}

/// Verifies placeholder parsing and resolution for `dollar quote tag must be identifier`.
#[test]
fn dollar_quote_tag_must_be_identifier() {
    let parts = collect_parts("SELECT $123$ FROM t");
    assert_eq!(parts, vec![PlaceholderPart::Sql("SELECT $123$ FROM t")]);
}

/// Verifies placeholder parsing and resolution for `dollar quote nested dollar signs`.
#[test]
fn dollar_quote_nested_dollar_signs() {
    let parts = collect_parts("SELECT $$text $ more$$ FROM t");
    assert_eq!(
        parts,
        vec![PlaceholderPart::Sql("SELECT $$text $ more$$ FROM t")]
    );
}

/// Verifies placeholder parsing and resolution for `dollar quote tag prefix matching`.
#[test]
fn dollar_quote_tag_prefix_matching() {
    // $tag$ should not match $tagg$
    let parts = collect_parts("SELECT $tag$text$tagg$ FROM t");
    assert_eq!(
        parts,
        vec![PlaceholderPart::Sql("SELECT $tag$text$tagg$ FROM t")]
    );
}

/// Verifies placeholder parsing and resolution for `placeholder before and after quotes`.
#[test]
fn placeholder_before_and_after_quotes() {
    let parts = collect_parts(":a 'text' :b");
    assert_eq!(
        parts,
        vec![
            PlaceholderPart::Placeholder("a"),
            PlaceholderPart::Sql(" 'text' "),
            PlaceholderPart::Placeholder("b"),
        ]
    );
}

/// Verifies placeholder parsing and resolution for `complex query with multiple features`.
#[test]
fn complex_query_with_multiple_features() {
    let sql = r#"
            SELECT * FROM users
            WHERE id = :id -- user id
              AND name = 'O''Neil :fake'
              AND email = :email /* :notthis */
              AND data = $${"key": ":value"}$$
              AND status::text = :status
        "#;
    let parts = parts_to_strings(collect_parts(sql));
    assert!(parts.contains(&"PARAM:id".to_string()));
    assert!(parts.contains(&"PARAM:email".to_string()));
    assert!(parts.contains(&"PARAM:status".to_string()));
    assert!(!parts.iter().any(|s| s.contains("PARAM:fake")));
    assert!(!parts.iter().any(|s| s.contains("PARAM:notthis")));
    assert!(!parts.iter().any(|s| s.contains("PARAM:value")));
}

/// Verifies placeholder parsing and resolution for `placeholder after various punctuation`.
#[test]
fn placeholder_after_various_punctuation() {
    let parts = collect_parts("(:a, :b):c {:d}");
    assert_eq!(
        parts_to_strings(parts),
        vec![
            "SQL:(".to_string(),
            "PARAM:a".to_string(),
            "SQL:, ".to_string(),
            "PARAM:b".to_string(),
            "SQL:)".to_string(),
            "PARAM:c".to_string(),
            "SQL: {".to_string(),
            "PARAM:d".to_string(),
            "SQL:}".to_string(),
        ]
    );
}

/// Verifies placeholder parsing and resolution for `unclosed single quote`.
#[test]
fn unclosed_single_quote() {
    let parts = collect_parts("SELECT ':param");
    assert_eq!(parts, vec![PlaceholderPart::Sql("SELECT ':param")]);
}

/// Verifies placeholder parsing and resolution for `unclosed double quote`.
#[test]
fn unclosed_double_quote() {
    let parts = collect_parts("SELECT \":param");
    assert_eq!(parts, vec![PlaceholderPart::Sql("SELECT \":param")]);
}

/// Verifies placeholder parsing and resolution for `unclosed backtick`.
#[test]
fn unclosed_backtick() {
    let parts = collect_parts("SELECT `:param");
    assert_eq!(parts, vec![PlaceholderPart::Sql("SELECT `:param")]);
}

/// Verifies placeholder parsing and resolution for `unclosed bracket ident`.
#[test]
fn unclosed_bracket_ident() {
    let parts = collect_parts("SELECT [:param");
    assert_eq!(parts, vec![PlaceholderPart::Sql("SELECT [:param")]);
}

/// Verifies placeholder parsing and resolution for `unclosed dollar quote`.
#[test]
fn unclosed_dollar_quote() {
    let parts = collect_parts("SELECT $$:param");
    assert_eq!(parts, vec![PlaceholderPart::Sql("SELECT $$:param")]);
}

/// Verifies placeholder parsing and resolution for `empty placeholder name`.
#[test]
fn empty_placeholder_name() {
    // : followed by space
    let parts = collect_parts("SELECT : FROM t");
    assert_eq!(parts, vec![PlaceholderPart::Sql("SELECT : FROM t")]);
}

/// Verifies placeholder parsing and resolution for `consecutive placeholders`.
#[test]
fn consecutive_placeholders() {
    let parts = collect_parts(":a:b:c");
    assert_eq!(
        parts_to_strings(parts),
        vec![
            "PARAM:a".to_string(),
            "PARAM:b".to_string(),
            "PARAM:c".to_string(),
        ]
    );
}

/// Verifies placeholder parsing and resolution for `placeholder with operators`.
#[test]
fn placeholder_with_operators() {
    let parts = collect_parts("SELECT :a+:b*:c");
    assert_eq!(
        parts_to_strings(parts),
        vec![
            "SQL:SELECT ".to_string(),
            "PARAM:a".to_string(),
            "SQL:+".to_string(),
            "PARAM:b".to_string(),
            "SQL:*".to_string(),
            "PARAM:c".to_string(),
        ]
    );
}

/// Verifies placeholder parsing and resolution for `all quote types in sequence`.
#[test]
fn all_quote_types_in_sequence() {
    let parts = collect_parts("':a' \":b\" `:c` [:d] $$:e$$");
    assert_eq!(
        parts,
        vec![PlaceholderPart::Sql("':a' \":b\" `:c` [:d] $$:e$$")]
    );
}

/// Verifies placeholder parsing and resolution for `mixed comment types`.
#[test]
fn mixed_comment_types() {
    let parts = collect_parts("-- :a\n/* :b */ # :c\n:d");
    assert_eq!(
        parts,
        vec![
            PlaceholderPart::Sql("-- :a\n/* :b */ # :c\n"),
            PlaceholderPart::Placeholder("d"),
        ]
    );
}

/// Verifies placeholder parsing and resolution for `backslash at string end boundary`.
#[test]
fn backslash_at_string_end_boundary() {
    // Backslash at end of input inside quote
    let parts = collect_parts("SELECT 'text\\");
    assert_eq!(parts, vec![PlaceholderPart::Sql("SELECT 'text\\")]);
}

/// Verifies placeholder parsing and resolution for `single colon`.
#[test]
fn single_colon() {
    let parts = collect_parts(":");
    assert_eq!(parts, vec![PlaceholderPart::Sql(":")]);
}

/// Verifies placeholder parsing and resolution for `only placeholder`.
#[test]
fn only_placeholder() {
    let parts = collect_parts(":param");
    assert_eq!(parts, vec![PlaceholderPart::Placeholder("param")]);
}

/// Verifies placeholder parsing and resolution for `placeholder uppercase letters`.
#[test]
fn placeholder_uppercase_letters() {
    let parts = collect_parts(":USER_ID :UserName");
    assert_eq!(
        parts,
        vec![
            PlaceholderPart::Placeholder("USER_ID"),
            PlaceholderPart::Sql(" "),
            PlaceholderPart::Placeholder("UserName"),
        ]
    );
}

/// Verifies placeholder parsing and resolution for `dollar sign not quote start`.
#[test]
fn dollar_sign_not_quote_start() {
    let parts = collect_parts("SELECT $ :param FROM t");
    assert_eq!(
        parts,
        vec![
            PlaceholderPart::Sql("SELECT $ "),
            PlaceholderPart::Placeholder("param"),
            PlaceholderPart::Sql(" FROM t"),
        ]
    );
}

/// Verifies placeholder parsing and resolution for `star slash outside comment`.
#[test]
fn star_slash_outside_comment() {
    let parts = collect_parts("SELECT */ :param");
    assert_eq!(
        parts,
        vec![
            PlaceholderPart::Sql("SELECT */ "),
            PlaceholderPart::Placeholder("param"),
        ]
    );
}

/// Verifies placeholder parsing and resolution for `dash not double`.
#[test]
fn dash_not_double() {
    let parts = collect_parts("SELECT - :param");
    assert_eq!(
        parts,
        vec![
            PlaceholderPart::Sql("SELECT - "),
            PlaceholderPart::Placeholder("param"),
        ]
    );
}

/// Verifies placeholder parsing and resolution for `has placeholder returns true`.
#[test]
fn has_placeholder_returns_true() {
    assert!(has_named_placeholder("SELECT * WHERE id = :id"));
    assert!(has_named_placeholder(":param"));
    assert!(has_named_placeholder("text :param more"));
}

/// Verifies placeholder parsing and resolution for `has placeholder returns false`.
#[test]
fn has_placeholder_returns_false() {
    assert!(!has_named_placeholder("SELECT * FROM users"));
    assert!(!has_named_placeholder(""));
    assert!(!has_named_placeholder("SELECT ':param' FROM t"));
    assert!(!has_named_placeholder("-- :param"));
    assert!(!has_named_placeholder("id::integer"));
}

/// Verifies placeholder parsing and resolution for `has placeholder short circuits`.
#[test]
fn has_placeholder_short_circuits() {
    // Should stop at first placeholder without scanning entire string
    assert!(has_named_placeholder(":first :second :third"));
}

/// Verifies placeholder parsing and resolution for `has placeholder incomplete single quote`.
#[test]
fn has_placeholder_incomplete_single_quote() {
    // Unclosed quote - placeholder before quote should be found
    assert!(has_named_placeholder(":param 'unclosed"));
    // Unclosed quote - placeholder inside quote should be ignored
    assert!(!has_named_placeholder("'unclosed :param"));
}

/// Verifies placeholder parsing and resolution for `has placeholder incomplete double quote`.
#[test]
fn has_placeholder_incomplete_double_quote() {
    // Unclosed double quote
    assert!(has_named_placeholder(":param \"unclosed"));
    assert!(!has_named_placeholder("\"unclosed :param"));
}

/// Verifies placeholder parsing and resolution for `has placeholder incomplete backtick`.
#[test]
fn has_placeholder_incomplete_backtick() {
    // Unclosed backtick
    assert!(has_named_placeholder(":param `unclosed"));
    assert!(!has_named_placeholder("`unclosed :param"));
}

/// Verifies placeholder parsing and resolution for `has placeholder incomplete bracket`.
#[test]
fn has_placeholder_incomplete_bracket() {
    // Unclosed bracket identifier
    assert!(has_named_placeholder(":param [unclosed"));
    assert!(!has_named_placeholder("[unclosed :param"));
}

/// Verifies placeholder parsing and resolution for `has placeholder incomplete line comment`.
#[test]
fn has_placeholder_incomplete_line_comment() {
    // Line comment without newline - placeholder in comment ignored
    assert!(!has_named_placeholder("-- :param"));
    assert!(!has_named_placeholder("# :param"));
    // Placeholder before comment found
    assert!(has_named_placeholder(":param --"));
}

/// Verifies placeholder parsing and resolution for `has placeholder incomplete block comment`.
#[test]
fn has_placeholder_incomplete_block_comment() {
    // Unclosed block comment - placeholder inside ignored
    assert!(!has_named_placeholder("/* :param"));
    // Placeholder before unclosed comment found
    assert!(has_named_placeholder(":param /*"));
}

/// Verifies placeholder parsing and resolution for `has placeholder incomplete dollar quote`.
#[test]
fn has_placeholder_incomplete_dollar_quote() {
    // Incomplete dollar quote
    assert!(has_named_placeholder(":param $$text"));
    assert!(has_named_placeholder(":param $tag$text"));
    // Placeholder inside unclosed dollar quote
    assert!(!has_named_placeholder("$$:param"));
    assert!(!has_named_placeholder("$tag$:param"));
}

/// Verifies placeholder parsing and resolution for `has placeholder partial placeholder`.
#[test]
fn has_placeholder_partial_placeholder() {
    // Colon at end of string
    assert!(!has_named_placeholder("SELECT :"));
    // Colon followed by non-name char
    assert!(!has_named_placeholder("SELECT :123"));
    // Incomplete placeholder name is still a placeholder
    assert!(has_named_placeholder("SELECT :p"));
}

/// Verifies placeholder parsing and resolution for `has placeholder escaped quote incomplete`.
#[test]
fn has_placeholder_escaped_quote_incomplete() {
    // Escaped quote at end - string still open
    assert!(!has_named_placeholder("'text\\' :param"));
    // Note: 'text\' leaves quote open, :param is inside the string context
}

/// Verifies placeholder parsing and resolution for `has placeholder mixed incomplete`.
#[test]
fn has_placeholder_mixed_incomplete() {
    // Multiple incomplete constructs
    assert!(has_named_placeholder(":a /* :b"));
    assert!(has_named_placeholder(":a 'b"));
    assert!(!has_named_placeholder("'a :b /* :c"));
    assert!(!has_named_placeholder("/* 'quoted :param"));
}

/// Verifies placeholder parsing and resolution for `has placeholder empty and whitespace`.
#[test]
fn has_placeholder_empty_and_whitespace() {
    assert!(!has_named_placeholder(""));
    assert!(!has_named_placeholder("   "));
    assert!(!has_named_placeholder("\n\t"));
}

/// Verifies placeholder parsing and resolution for `has placeholder only special chars`.
#[test]
fn has_placeholder_only_special_chars() {
    assert!(!has_named_placeholder("::::"));
    assert!(!has_named_placeholder("/* */ -- "));
    assert!(!has_named_placeholder("'''' \"\" ``"));
}