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
//! The two places a statement built at runtime still has to name its dialect.
//!
//! Almost all SQL Arcature writes is either fixed text living behind
//! [`crate::jobs`]'s own per-dialect seam or a SeaORM query that renders
//! itself. What is left is the handful of statements assembled from a table
//! name and a list of columns -- the test kit's `assert_database_has` is the
//! whole of it today -- and those hit exactly two portability walls:
//!
//! 1. **Placeholders.** PostgreSQL numbers them `$1`, `$2`; MySQL and SQLite
//! both write `?`. Getting this wrong is not a subtle failure -- the
//! statement does not parse -- but it does mean the same `format!` cannot
//! serve all three.
//! 2. **Casting to text.** Comparing a bound `&str` against a column of any
//! type needs the column cast, and `CAST(x AS TEXT)` is not universal:
//! MySQL's `CAST` has no `TEXT` target and wants `CHAR`. PostgreSQL and
//! SQLite both accept `TEXT`, so this is two arms rather than three.
//!
//! Both helpers render text that is then interpolated into a statement, so
//! neither may ever be handed caller data. They take an index and an
//! already-validated identifier for that reason.
/// Render the placeholder for the `index`-th bound parameter, counting from 1.
///
/// The index is ignored on MySQL and SQLite, which have only positional `?`.
/// It is still required, because a caller that does not track its own
/// parameter numbering will bind them in the wrong order on PostgreSQL and
/// pass every test run against the other two.
pub
/// Render the placeholder for the `index`-th bound parameter, counting from 1.
/// See the PostgreSQL arm for why `index` is required but unused here.
pub
/// Wrap `column` in a cast to the dialect's text type.
///
/// `column` is interpolated into the statement, so it must already have been
/// validated as a plain identifier by the caller.
pub
/// Wrap `column` in a cast to the dialect's text type. MySQL's `CAST` has no
/// `TEXT` target; `CHAR` is the spelling that works there.
pub