File tree 5 files changed +33
-5
lines changed
5 files changed +33
-5
lines changed Original file line number Diff line number Diff line change @@ -223,7 +223,10 @@ impl Migrate for AnyConnection {
223
223
AnyConnectionKind :: MySql ( conn) => conn. revert ( migration) ,
224
224
225
225
#[ cfg( feature = "mssql" ) ]
226
- AnyConnectionKind :: Mssql ( _conn) => unimplemented ! ( ) ,
226
+ AnyConnectionKind :: Mssql ( _conn) => {
227
+ let _ = migration;
228
+ unimplemented ! ( )
229
+ }
227
230
}
228
231
}
229
232
}
Original file line number Diff line number Diff line change @@ -138,9 +138,32 @@ impl<C: DerefMut<Target = PgConnection>> PgCopyIn<C> {
138
138
} )
139
139
}
140
140
141
+ /// Returns `true` if Postgres is expecting data in text or CSV format.
142
+ pub fn is_textual ( & self ) -> bool {
143
+ self . response . format == 0
144
+ }
145
+
146
+ /// Returns the number of columns expected in the input.
147
+ pub fn num_columns ( & self ) -> usize {
148
+ assert_eq ! (
149
+ self . response. num_columns as usize ,
150
+ self . response. format_codes. len( ) ,
151
+ "num_columns does not match format_codes.len()"
152
+ ) ;
153
+ self . response . format_codes . len ( )
154
+ }
155
+
156
+ /// Check if a column is expecting data in text format (`true`) or binary format (`false`).
157
+ ///
158
+ /// ### Panics
159
+ /// If `column` is out of range according to [`.num_columns()`][Self::num_columns].
160
+ pub fn column_is_textual ( & self , column : usize ) -> bool {
161
+ self . response . format_codes [ column] == 0
162
+ }
163
+
141
164
/// Send a chunk of `COPY` data.
142
165
///
143
- /// If you're copying data from an `AsyncRead`, maybe consider [Self::copy_from ] instead.
166
+ /// If you're copying data from an `AsyncRead`, maybe consider [Self::read_from ] instead.
144
167
pub async fn send ( & mut self , data : impl Deref < Target = [ u8 ] > ) -> Result < & mut Self > {
145
168
self . conn
146
169
. as_deref_mut ( )
Original file line number Diff line number Diff line change @@ -88,7 +88,8 @@ impl TryFrom<&'_ Decimal> for PgNumeric {
88
88
type Error = BoxDynError ;
89
89
90
90
fn try_from ( decimal : & Decimal ) -> Result < Self , BoxDynError > {
91
- if decimal. is_zero ( ) {
91
+ // `Decimal` added `is_zero()` as an inherent method in a more recent version
92
+ if Zero :: is_zero ( decimal) {
92
93
return Ok ( PgNumeric :: Number {
93
94
sign : PgNumericSign :: Positive ,
94
95
scale : 0 ,
Original file line number Diff line number Diff line change @@ -1148,7 +1148,7 @@ async fn it_can_abort_copy_in() -> anyhow::Result<()> {
1148
1148
)
1149
1149
. await ?;
1150
1150
1151
- let mut copy = conn
1151
+ let copy = conn
1152
1152
. copy_in_raw (
1153
1153
r#"
1154
1154
COPY users (id) FROM STDIN WITH (FORMAT CSV, HEADER);
@@ -1201,6 +1201,7 @@ async fn it_can_copy_out() -> anyhow::Result<()> {
1201
1201
Ok ( ( ) )
1202
1202
}
1203
1203
1204
+ #[ sqlx_macros:: test]
1204
1205
async fn test_issue_1254 ( ) -> anyhow:: Result < ( ) > {
1205
1206
#[ derive( sqlx:: Type ) ]
1206
1207
#[ sqlx( type_name = "pair" ) ]
Original file line number Diff line number Diff line change 1
1
use sqlx:: Sqlite ;
2
- use sqlx_test:: { new , test_type} ;
2
+ use sqlx_test:: test_type;
3
3
4
4
#[ derive( Debug , PartialEq , sqlx:: Type ) ]
5
5
#[ repr( u32 ) ]
You can’t perform that action at this time.
0 commit comments