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
//! Database identifier quoting utilities.
//!
//! This module provides database-specific identifier quoting functions that handle
//! schema-qualified identifiers (e.g., `schema.table`, `catalog.schema.table`).
//!
//! Each function splits on `.` and quotes each component with the appropriate syntax
//! for the target database.
/// Quote a PostgreSQL identifier.
///
/// PostgreSQL uses double quotes for identifiers. Schema-qualified names
/// (e.g., `schema.table`) are split and quoted per component.
///
/// # Examples
///
/// ```rust
/// use fraiseql_db::quote_postgres_identifier;
/// assert_eq!(quote_postgres_identifier("v_user"), "\"v_user\"");
/// assert_eq!(quote_postgres_identifier("benchmark.v_user"), "\"benchmark\".\"v_user\"");
/// assert_eq!(
/// quote_postgres_identifier("catalog.schema.table"),
/// "\"catalog\".\"schema\".\"table\""
/// );
/// ```
/// Quote a MySQL identifier.
///
/// MySQL uses backticks for identifiers. Schema-qualified names
/// (e.g., `database.table`) are split and quoted per component.
///
/// # Examples
///
/// ```rust
/// use fraiseql_db::quote_mysql_identifier;
/// assert_eq!(quote_mysql_identifier("v_user"), "`v_user`");
/// assert_eq!(quote_mysql_identifier("mydb.v_user"), "`mydb`.`v_user`");
/// assert_eq!(
/// quote_mysql_identifier("catalog.schema.table"),
/// "`catalog`.`schema`.`table`"
/// );
/// ```
/// Quote a SQLite identifier.
///
/// SQLite uses double quotes for identifiers. Schema-qualified names
/// (e.g., `schema.table`) are split and quoted per component.
///
/// # Examples
///
/// ```rust
/// use fraiseql_db::quote_sqlite_identifier;
/// assert_eq!(quote_sqlite_identifier("v_user"), "\"v_user\"");
/// assert_eq!(quote_sqlite_identifier("main.v_user"), "\"main\".\"v_user\"");
/// assert_eq!(
/// quote_sqlite_identifier("catalog.schema.table"),
/// "\"catalog\".\"schema\".\"table\""
/// );
/// ```
/// Quote a SQL Server identifier.
///
/// SQL Server uses square brackets for identifiers. Schema-qualified names
/// (e.g., `schema.table`) are split and quoted per component.
///
/// # Examples
///
/// ```rust
/// use fraiseql_db::quote_sqlserver_identifier;
/// assert_eq!(quote_sqlserver_identifier("v_user"), "[v_user]");
/// assert_eq!(quote_sqlserver_identifier("dbo.v_user"), "[dbo].[v_user]");
/// assert_eq!(
/// quote_sqlserver_identifier("catalog.schema.table"),
/// "[catalog].[schema].[table]"
/// );
/// ```