@@ -351,6 +351,44 @@ fn test_in_subquery_multiple_columns() -> Result<(), Box<dyn std::error::Error>>
351
351
. collect:: <Vec <_>>( ) ,
352
352
vec![ "Select only one column in the subquery" ]
353
353
) ;
354
+ Ok ( ( ) )
355
+ }
354
356
357
+ #[ test]
358
+ fn test_unary_op_plus_with_column ( ) -> Result < ( ) > {
359
+ // Test with a direct query that references a column with an incompatible type
360
+ let query = "SELECT +/*whole*/first_name/*whole*/ FROM person" ;
361
+ let spans = get_spans ( query) ;
362
+ let diag = do_query ( query) ;
363
+ assert_eq ! ( diag. message, "+ cannot be used with Utf8" ) ;
364
+ assert_eq ! ( diag. span, Some ( spans[ "whole" ] ) ) ;
365
+ assert_eq ! (
366
+ diag. notes[ 0 ] . message,
367
+ "+ can only be used with numbers, intervals, and timestamps"
368
+ ) ;
369
+ assert_eq ! (
370
+ diag. helps[ 0 ] . message,
371
+ "perhaps you need to cast person.first_name"
372
+ ) ;
373
+ Ok ( ( ) )
374
+ }
375
+
376
+ #[ test]
377
+ fn test_unary_op_plus_with_non_column ( ) -> Result < ( ) > {
378
+ // create a table with a column of type varchar
379
+ let query = "SELECT +'a'" ;
380
+ let diag = do_query ( query) ;
381
+ assert_eq ! ( diag. message, "+ cannot be used with Utf8" ) ;
382
+ assert_eq ! (
383
+ diag. notes[ 0 ] . message,
384
+ "+ can only be used with numbers, intervals, and timestamps"
385
+ ) ;
386
+ assert_eq ! ( diag. notes[ 0 ] . span, None ) ;
387
+ assert_eq ! (
388
+ diag. helps[ 0 ] . message,
389
+ "perhaps you need to cast Utf8(\" a\" )"
390
+ ) ;
391
+ assert_eq ! ( diag. helps[ 0 ] . span, None ) ;
392
+ assert_eq ! ( diag. span, None ) ;
355
393
Ok ( ( ) )
356
394
}
0 commit comments