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
use ;
/// Returns the name of the type `T` as a string.
///
/// # Arguments
///
/// * `value` - A value of type `T`.
///
/// # Returns
///
/// * A string slice that represents the name of the type `T`.
///
/// # Example
///
/// ```
/// let type_name = get_type_name(42);
/// assert_eq!(type_name, "i32");
/// ```
/// Retrieves a placeholder for SQL queries based on the `DATABASE_URL` environment variable.
///
/// # Returns
///
/// * `Ok("?")` if the database is SQLite or MySQL.
/// * `Ok("$")` if the database is PostgreSQL.
/// * `Err` if the `DATABASE_URL` environment variable is not set or if the database type is unsupported.
///
/// # Errors
///
/// Returns an `std::io::Error` if the `DATABASE_URL` is not found or if the database type is unsupported.
///
/// # Example
///
/// ```
/// std::env::set_var("DATABASE_URL", "sqlite://database.db");
/// let placeholder = get_placeholder().unwrap();
/// assert_eq!(placeholder, "?");
/// ```
/// Converts a value into a JSON string.
///
/// # Arguments
///
/// * `value` - A value that can be converted into `serde_json::Value`.
///
/// # Returns
///
/// * A `String` representation of the JSON value.
/// * If the value is a boolean, it converts `true` to `1` and `false` to `0`.
///
/// # Example
///
/// ```
/// let json_string = to_string(true);
/// assert_eq!(json_string, "1");
///
/// let json_string = to_string("Hello");
/// assert_eq!(json_string, "\"Hello\"");
/// ```