@@ -30,7 +30,7 @@ use std::str::FromStr;
30
30
#[ derive( Clone , PartialEq , Eq , Hash , PartialOrd , Ord ) ]
31
31
pub struct Column {
32
32
/// relation/table reference.
33
- pub relation : Option < TableReference > ,
33
+ pub relation : Box < Option < TableReference > > ,
34
34
/// field/column name.
35
35
pub name : String ,
36
36
/// Original source code location, if known
@@ -58,7 +58,7 @@ impl Column {
58
58
name : impl Into < String > ,
59
59
) -> Self {
60
60
Self {
61
- relation : relation. map ( |r| r. into ( ) ) ,
61
+ relation : Box :: new ( relation. map ( |r| r. into ( ) ) ) ,
62
62
name : name. into ( ) ,
63
63
spans : Spans :: new ( ) ,
64
64
}
@@ -67,7 +67,7 @@ impl Column {
67
67
/// Convenience method for when there is no qualifier
68
68
pub fn new_unqualified ( name : impl Into < String > ) -> Self {
69
69
Self {
70
- relation : None ,
70
+ relation : Box :: new ( None ) ,
71
71
name : name. into ( ) ,
72
72
spans : Spans :: new ( ) ,
73
73
}
@@ -78,7 +78,7 @@ impl Column {
78
78
/// Alias for `Column::new_unqualified`
79
79
pub fn from_name ( name : impl Into < String > ) -> Self {
80
80
Self {
81
- relation : None ,
81
+ relation : Box :: new ( None ) ,
82
82
name : name. into ( ) ,
83
83
spans : Spans :: new ( ) ,
84
84
}
@@ -116,6 +116,8 @@ impl Column {
116
116
// identifiers will be treated as an unqualified column name
117
117
_ => return None ,
118
118
} ;
119
+
120
+ let relation = Box :: new ( relation) ;
119
121
Some ( Self {
120
122
relation,
121
123
name,
@@ -132,7 +134,7 @@ impl Column {
132
134
let flat_name = flat_name. into ( ) ;
133
135
Self :: from_idents ( parse_identifiers_normalized ( & flat_name, false ) ) . unwrap_or_else (
134
136
|| Self {
135
- relation : None ,
137
+ relation : Box :: new ( None ) ,
136
138
name : flat_name,
137
139
spans : Spans :: new ( ) ,
138
140
} ,
@@ -144,7 +146,7 @@ impl Column {
144
146
let flat_name = flat_name. into ( ) ;
145
147
Self :: from_idents ( parse_identifiers_normalized ( & flat_name, true ) ) . unwrap_or_else (
146
148
|| Self {
147
- relation : None ,
149
+ relation : Box :: new ( None ) ,
148
150
name : flat_name,
149
151
spans : Spans :: new ( ) ,
150
152
} ,
@@ -160,15 +162,15 @@ impl Column {
160
162
161
163
/// Serialize column into a flat name string
162
164
pub fn flat_name ( & self ) -> String {
163
- match & self . relation {
165
+ match & * self . relation {
164
166
Some ( r) => format ! ( "{}.{}" , r, self . name) ,
165
167
None => self . name . clone ( ) ,
166
168
}
167
169
}
168
170
169
171
/// Serialize column into a quoted flat name string
170
172
pub fn quoted_flat_name ( & self ) -> String {
171
- match & self . relation {
173
+ match & * self . relation {
172
174
Some ( r) => {
173
175
format ! (
174
176
"{}.{}" ,
@@ -316,7 +318,7 @@ impl Column {
316
318
/// Qualifies the column with the given table reference.
317
319
pub fn with_relation ( & self , relation : TableReference ) -> Self {
318
320
Self {
319
- relation : Some ( relation) ,
321
+ relation : Box :: new ( Some ( relation) ) ,
320
322
..self . clone ( )
321
323
}
322
324
}
0 commit comments