File tree Expand file tree Collapse file tree 2 files changed +33
-23
lines changed Expand file tree Collapse file tree 2 files changed +33
-23
lines changed Original file line number Diff line number Diff line change @@ -769,8 +769,6 @@ def test_execute_illegal_sql(self):
769
769
with self .assertRaises (sqlite .OperationalError ):
770
770
self .cu .execute ("select asdf" )
771
771
772
- # TODO: RUSTPYTHON
773
- @unittest .expectedFailure
774
772
def test_execute_multiple_statements (self ):
775
773
msg = "You can only execute one statement at a time"
776
774
dataset = (
@@ -793,8 +791,6 @@ def test_execute_multiple_statements(self):
793
791
with self .assertRaisesRegex (sqlite .ProgrammingError , msg ):
794
792
self .cu .execute (query )
795
793
796
- # TODO: RUSTPYTHON
797
- @unittest .expectedFailure
798
794
def test_execute_with_appended_comments (self ):
799
795
dataset = (
800
796
"select 1; -- foo bar" ,
@@ -963,8 +959,6 @@ def test_rowcount_update_returning(self):
963
959
self .assertEqual (self .cu .fetchone ()[0 ], 1 )
964
960
self .assertEqual (self .cu .rowcount , 1 )
965
961
966
- # TODO: RUSTPYTHON
967
- @unittest .expectedFailure
968
962
def test_rowcount_prefixed_with_comment (self ):
969
963
# gh-79579: rowcount is updated even if query is prefixed with comments
970
964
self .cu .execute ("""
Original file line number Diff line number Diff line change @@ -3068,36 +3068,52 @@ mod _sqlite {
3068
3068
}
3069
3069
3070
3070
fn lstrip_sql ( sql : & [ u8 ] ) -> Option < & [ u8 ] > {
3071
- let mut pos = sql;
3072
- loop {
3073
- match pos. first ( ) ? {
3071
+ let mut pos = 0 ;
3072
+
3073
+ // This loop is borrowed from the SQLite source code.
3074
+ while let Some ( t_char) = sql. get ( pos) {
3075
+ match t_char {
3074
3076
b' ' | b'\t' | b'\x0c' | b'\n' | b'\r' => {
3075
- pos = & pos[ 1 ..] ;
3077
+ // Skip whitespace.
3078
+ pos += 1 ;
3076
3079
}
3077
3080
b'-' => {
3078
- if * pos. get ( 1 ) ? == b'-' {
3079
- // line comments
3080
- pos = & pos[ 2 ..] ;
3081
- while * pos. first ( ) ? != b'\n' {
3082
- pos = & pos[ 1 ..] ;
3081
+ // Skip line comments.
3082
+ if sql. get ( pos + 1 ) == Some ( & b'-' ) {
3083
+ pos += 2 ;
3084
+ while let Some ( & ch) = sql. get ( pos) {
3085
+ if ch == b'\n' {
3086
+ break ;
3087
+ }
3088
+ pos += 1 ;
3083
3089
}
3090
+ let _ = sql. get ( pos) ?;
3084
3091
} else {
3085
- return Some ( pos) ;
3092
+ return Some ( & sql [ pos.. ] ) ;
3086
3093
}
3087
3094
}
3088
3095
b'/' => {
3089
- if * pos. get ( 1 ) ? == b'*' {
3090
- // c style comments
3091
- pos = & pos[ 2 ..] ;
3092
- while * pos. first ( ) ? != b'*' || * pos. get ( 1 ) ? != b'/' {
3093
- pos = & pos[ 1 ..] ;
3096
+ // Skip C style comments.
3097
+ if sql. get ( pos + 1 ) == Some ( & b'*' ) {
3098
+ pos += 2 ;
3099
+ while let Some ( & ch) = sql. get ( pos) {
3100
+ if ch == b'*' && sql. get ( pos + 1 ) == Some ( & b'/' ) {
3101
+ break ;
3102
+ }
3103
+ pos += 1 ;
3094
3104
}
3105
+ let _ = sql. get ( pos) ?;
3106
+ pos += 2 ;
3095
3107
} else {
3096
- return Some ( pos) ;
3108
+ return Some ( & sql [ pos.. ] ) ;
3097
3109
}
3098
3110
}
3099
- _ => return Some ( pos) ,
3111
+ _ => {
3112
+ return Some ( & sql[ pos..] ) ;
3113
+ }
3100
3114
}
3101
3115
}
3116
+
3117
+ None
3102
3118
}
3103
3119
}
You can’t perform that action at this time.
0 commit comments