File tree Expand file tree Collapse file tree 2 files changed +39
-23
lines changed Expand file tree Collapse file tree 2 files changed +39
-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,58 @@ 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
+ while let Some ( current_char ) = sql . get ( pos ) {
3073
+ match current_char {
3074
3074
b' ' | b'\t' | b'\x0c' | b'\n' | b'\r' => {
3075
- pos = & pos[ 1 ..] ;
3075
+ // Skip whitespace.
3076
+ pos += 1 ;
3076
3077
}
3077
3078
b'-' => {
3078
- if * pos. get ( 1 ) ? == b'-' {
3079
- // line comments
3080
- pos = & pos[ 2 ..] ;
3081
- while * pos. first ( ) ? != b'\n' {
3082
- pos = & pos[ 1 ..] ;
3079
+ // Skip line comments.
3080
+ if sql. get ( pos + 1 ) == Some ( & b'-' ) {
3081
+ pos += 2 ;
3082
+ while let Some ( ch) = sql. get ( pos) {
3083
+ if * ch == b'\n' {
3084
+ break ;
3085
+ }
3086
+ pos += 1 ;
3087
+ }
3088
+ // CPython: if (pos[0] == '\0') return NULL;
3089
+ if sql. get ( pos) . is_none ( ) {
3090
+ return None ;
3083
3091
}
3092
+ // CPython: continue; (The outer for loop handles pos++)
3093
+ // Rust: The outer while loop will continue naturally
3084
3094
} else {
3085
- return Some ( pos) ;
3095
+ return Some ( & sql [ pos.. ] ) ;
3086
3096
}
3087
3097
}
3088
3098
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 ..] ;
3099
+ // Skip C style comments.
3100
+ if sql. get ( pos + 1 ) == Some ( & b'*' ) {
3101
+ pos += 2 ;
3102
+ while let Some ( ch) = sql. get ( pos) {
3103
+ if * ch == b'*' && sql. get ( pos + 1 ) == Some ( & b'/' ) {
3104
+ break ;
3105
+ }
3106
+ pos += 1 ;
3094
3107
}
3108
+ // CPython: if (pos[0] == '\0') return NULL;
3109
+ if sql. get ( pos) . is_none ( ) {
3110
+ return None ; // Unclosed comment
3111
+ }
3112
+ // CPython: pos++; continue; (Handles '*' then '/' in the next loop)
3113
+ pos += 2 ; // Skip "*/"
3095
3114
} else {
3096
- return Some ( pos) ;
3115
+ return Some ( & sql [ pos.. ] ) ;
3097
3116
}
3098
3117
}
3099
- _ => return Some ( pos) ,
3118
+ _ => {
3119
+ return Some ( & sql[ pos..] ) ;
3120
+ }
3100
3121
}
3101
3122
}
3123
+ None
3102
3124
}
3103
3125
}
You can’t perform that action at this time.
0 commit comments