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
// This file contains tests that should FAIL to compile
// to verify that the compile-time checks in custom select are working.
//
// To test these, temporarily uncomment one at a time and verify compilation fails.
use crateTable;
// COMPILE FAIL TEST 1: Using non-existent column in custom select
// Uncomment to verify this fails compilation with error about missing field
/*
#[derive(Output)]
#[sql(table = CompileFailTable)]
struct InvalidColumn {
id: i32,
#[sql(select = nonexistent_column || {arg0})]
name: String,
}
*/
// COMPILE FAIL TEST 2: Using column from wrong table
// Uncomment to verify this fails compilation
/*
#[derive(Table)]
#[sql(no_version)]
struct OtherTable {
#[sql(primary_key)]
id: i32,
other_field: String,
}
#[derive(Output)]
#[sql(table = CompileFailTable)]
struct WrongTableColumn {
id: i32,
#[sql(select = OtherTable.other_field)]
name: String,
}
*/
// COMPILE FAIL TEST 3: Using column with wrong type operation
// Uncomment to verify this fails compilation
/*
#[derive(Output)]
#[sql(table = CompileFailTable)]
struct WrongTypeOperation {
id: i32,
#[sql(select = name + age)] // Can't add string + number
name: String,
}
*/