File tree Expand file tree Collapse file tree 5 files changed +14
-7
lines changed Expand file tree Collapse file tree 5 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -755,6 +755,10 @@ impl TypeInfo for PgTypeInfo {
755
755
fn is_null ( & self ) -> bool {
756
756
false
757
757
}
758
+
759
+ fn is_void ( & self ) -> bool {
760
+ matches ! ( self . 0 , PgType :: Void )
761
+ }
758
762
}
759
763
760
764
impl PartialEq < PgCustomType > for PgCustomType {
Original file line number Diff line number Diff line change @@ -8,4 +8,9 @@ pub trait TypeInfo: Debug + Display + Clone + PartialEq<Self> + Send + Sync {
8
8
/// Common type names are `VARCHAR`, `TEXT`, or `INT`. Type names should be uppercase. They
9
9
/// should be a rough approximation of how they are written in SQL in the given database.
10
10
fn name ( & self ) -> & str ;
11
+
12
+ #[ doc( hidden) ]
13
+ fn is_void ( & self ) -> bool {
14
+ false
15
+ }
11
16
}
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ pub use input::QueryMacroInput;
9
9
use quote:: { format_ident, quote} ;
10
10
use sqlx_core:: connection:: Connection ;
11
11
use sqlx_core:: database:: Database ;
12
- use sqlx_core:: describe:: Describe ;
12
+ use sqlx_core:: { column :: Column , describe:: Describe , type_info :: TypeInfo } ;
13
13
use sqlx_rt:: block_on;
14
14
15
15
use crate :: database:: DatabaseExt ;
@@ -208,7 +208,7 @@ where
208
208
209
209
let query_args = format_ident ! ( "query_args" ) ;
210
210
211
- let output = if data. describe . columns ( ) . is_empty ( ) {
211
+ let output = if data. describe . columns ( ) . iter ( ) . all ( |it| it . type_info ( ) . is_void ( ) ) {
212
212
let db_path = DB :: db_path ( ) ;
213
213
let sql = & input. src ;
214
214
Original file line number Diff line number Diff line change 1
1
/// Statically checked SQL query with `println!()` style syntax.
2
2
///
3
3
/// This expands to an instance of [`query::Map`][crate::query::Map] that outputs an ad-hoc anonymous
4
- /// struct type, if the query has output columns , or `()` (unit) otherwise:
4
+ /// struct type, if the query has at least one output column that is not `Void` , or `()` (unit) otherwise:
5
5
///
6
6
/// ```rust,ignore
7
7
/// # use sqlx::Connect;
Original file line number Diff line number Diff line change @@ -89,12 +89,10 @@ async fn test_text_var_char_char_n() -> anyhow::Result<()> {
89
89
async fn test_void ( ) -> anyhow:: Result < ( ) > {
90
90
let mut conn = new :: < Postgres > ( ) . await ?;
91
91
92
- let record = sqlx:: query!( r#"select pg_notify('chan', 'message') as _1 "# )
93
- . fetch_one ( & mut conn)
92
+ let _ = sqlx:: query!( r#"select pg_notify('chan', 'message')"# )
93
+ . execute ( & mut conn)
94
94
. await ?;
95
95
96
- assert_eq ! ( record. _1, Some ( ( ) ) ) ;
97
-
98
96
Ok ( ( ) )
99
97
}
100
98
You can’t perform that action at this time.
0 commit comments